Repeat for each item - should it be more robust ?

Alex Tweedly alex at tweedly.net
Sun Feb 12 06:48:29 EST 2006


Martin Blackman wrote:

>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,
>  
>
messing with the repeat variable isn't "ill-advised" - it's "not allowed"
It will cause errors - the docs say that, and they're right.

>but I would have thought rev should be able to handle this.
>  
>
When the docs explicitly say

> Important!  You cannot change the labelVariable in a statement inside 
> the loop. Doing so will cause a script error. 

I think you should believe them :-)

-- 
Alex Tweedly       http://www.tweedly.net



-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.375 / Virus Database: 267.15.6/257 - Release Date: 10/02/2006




More information about the use-livecode mailing list