Clearing local variables

Bob Sneidar bobsneidar at iotecdigital.com
Fri Apr 29 11:12:58 EDT 2016


Agreed, but then you need to be careful about what any of your variables contain. :-)

As for tVar, I wasn't aware that you *could* modify it now. Last time I did this is when I started working with this repeat form, which I use religiously now, and ended up with scary nonsense in x. Apparently, the system moved the contents of the memory that was holding tVar when I modified it, but x was still using the old memory pointer index it creates when the repeat statement is first invoked.

I'd be curious to see how they got around this.

Bob S


On Apr 27, 2016, at 18:31 , Kay C Lan <lan.kc.macmail at gmail.com<mailto:lan.kc.macmail at gmail.com>> wrote:

well... to be clear, you can in a repeat with x = 1 to n form.


Well to be really clear you NEED to be careful if you intend to modify x or
tVar in both cases:

repeat with x = 1 to the number of items in tVar
repeat for each item x in tVar

If you do not understand what isn't 'variable' and what really gets checked
at each iteration for each style of repeat then you are likely to see some
unexpected results. On the other hand, if do understand what is really
going on, then you can modify x to your advantage in either case. As for
tVar in the 'repeat for each' case, I believe Mark Waddingham has cautioned
that although your scripts might currently work if you modify tVar mid
repeat, LC is NOT guaranteed to behave the same way in the future.




More information about the Use-livecode mailing list