just a comment

Ken Ray kray at sonsothunder.com
Tue Nov 28 18:04:13 EST 2006


On 11/28/06 12:36 AM, "Jim Ault" <JimAultWins at yahoo.com> wrote:

> On 11/27/06 10:03 PM, "John Vokey" <vokey at uleth.ca> wrote:
> 
>> All,
>>    One of my students got caught by the following in her stack:
>> 
>>    At the top of the card script, she declared some variables local
>> to the scripts of that card, as we always we do.  For one of these
>> variables, she did not initialise it in any way.  However, the use of
>> that variable is always done with ``put tab and someData after
>> thelocalvariable''.  No problem on first use, but the stack always
>> returns to the first cd of the stack to run the next subject, and
>> when it gets back to this cd, the local variable still exists (as if
>> it were a global), so the ``tab & someData'' gets added to the end of
>> the data from the previous run.  No big deal, as we can just clear
>> the variable in the opencard handler, but it is surprising, as local
>> variables are not supposed to be persistent, at least to my knowledge.
> 
> There are two kinds of 'local' variables...
> 
> script local
> --persistent
> --are only in the scope of that script
> 
> handler local  
> --they evaporate when the handler ends
> --they are only in the scope of that handler

IIRC, the variables do not get overwritten or cleared until the stack is
closed, so this is why the script local variables were still "working" when
you went back to the card.


Ken Ray
Sons of Thunder Software, Inc.
Web site: http://www.sonsothunder.com/
Email: kray at sonsothunder.com
 





More information about the Use-livecode mailing list