Re: just a comment

2006-11-28 Thread Ken Ray
On 11/28/06 12:36 AM, "Jim Ault" <[EMAIL PROTECTED]> wrote:

> On 11/27/06 10:03 PM, "John Vokey" <[EMAIL PROTECTED]> 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: [EMAIL PROTECTED]
 


___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: just a comment

2006-11-27 Thread Jim Ault
On 11/27/06 10:03 PM, "John Vokey" <[EMAIL PROTECTED]> 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


Exception: (rarely used, so ignore if it is confusing)
If the script of the container is set to empty by another Rev handler, then
set to a script including the same script local, the script local will lose
the original value.  For those interested, contact me for clarification, but
less than 0.0001 % of the Rev users will care about this.

Jim Ault
Las Vegas



___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: just a comment

2006-11-27 Thread Chipp Walters

Hi John,

Actually the behavior is correct. If you declare a local variable
OUTSIDE the other handlers of an object, it will stay persistent and
is accessible to all handlers/functions for that object.

This has some nifty benefits. It allows you to create persistent
variables, which aren't global (and therfore less likely to conflict),
and best of all, unlike custom properties, are automatically reset at
opening of a stack.

One thing to note, is the local variables are reinitialized to empty
during the editing of the script of the object-- at least this is the
behavior prior to 2.7. In 2.7, I believe, that behavior can be
changed, so they stay persistent even when editing the script.

You can also create a simple function to access the local variable
from outside the object. Say you have a group "test" with the script:

local lVar

function getlVar
  return lVar
end getlVar

then access it:

put value("getlVar", group "test")

HTH,
Chipp
___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


just a comment

2006-11-27 Thread John Vokey

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.


--
Please avoid sending me Word or PowerPoint attachments.
See 

-Dr. John R. Vokey




___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution