Repeat for each item - should it be more robust ?

Martin Blackman martinblackman at gmail.com
Sat Feb 11 21:55:08 EST 2006


Try the following script -

repeat for each item tItem in "apple,banana,broccoli"
if tItem = "broccoli" then put " - vegetable" after tItem else put " -
fruit" after tItem
answer tItem
end repeat

Rev answers 'apple - fruit', 'apple  - fruit' and 'broccolli - vegetable'
(There is an extra space in the second answer)

I know this is messing with the repeat variable which is ill-advised,
but I would have thought rev should be able to handle this.
It can be fixed by using a dummy variable, eg -

repeat for each item tItem in "apple,banana,broccoli"
if tItem = "broccoli" then put tItem&" - vegetable" into x else put
tItem&" - fruit" into x
answer x
end repeat


regards
Martin Blackman



More information about the use-livecode mailing list