Repeat for each item - should it be more robust ?
Mark Smith
mark at maseurope.net
Sun Feb 12 05:49:35 EST 2006
Well this is why messing with the repeat variable is ill-advised!
Not knowing exactly what the engine is doing while executing a repeat
for loop means we have no way of predicting the results should we ill-
advisedly mess with it. It seems that effectively lengthening the
repeat variable causes it to miscount items, so, as you demonstrate,
best not to to do it.
Why should rev be able to handle this, when it has clearly been
designed in such a way that it can't, and says so in the docs?
Mark
On 12 Feb 2006, at 02:55, 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,
> 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
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
More information about the use-livecode
mailing list