newbies: beware script locals

erik hansen erikhans08 at yahoo.com
Thu Feb 27 02:10:01 EST 2003


--- David Vaughan <dvk at dvkconsult.com.au> wrote:
> >> From: erik hansen <erikhans08 at yahoo.com>
> wrote:
> >
> >> Through use of custom props, script
> >> locals and ordinary variables, I have been
> able
> >> to relegate globals to very rare usage,
> >
> > when would you use "ordinary variables"
> instead
> > of "script locals"?
> >
> >> when you actually want a non-persistent
> > entirely
> >> global variable. Rev is quite rich in
> scoping
> >> and persistence options.
> >
> > "persistence" as a programming term is a new
> one
> > for me. how would a global variable
> non-persist?
> >
> > TIA
> >
> Erik
> 
> Perhaps I used some casual expression. By
> "ordinary variables" I meant 
> those whose whose scope was a single handler
> (declared or first used 
> within it) rather than "script locals" which
> are declared within a 
> script but outside handlers, thus giving them a
> script-wide scope and 
> session persistence - they retain their value
> until the application is 
> closed or the script recompiled.
> 
> A global variable nominally has script-wide
> scope but is also available 
> in any other script in which it is also
> declared, affording it 
> application-wide scope. A global has session
> persistence only, like a 
> script local, where a custom property persists
> through a stack close 
> (with save if changed)) and re-open. A custom
> property can be tied by 
> definition to various objects from a control to
> a stack, which 
> nominally suggests an intended scope but in
> practice they can be 
> referenced from anywhere. without any other
> declaration.
> 
> Hope this clarifies my meaning.

yes it does. so you always declare the variable
whether inside or outside the script?
that is what seems to be recommended.

=====
erik at erikhansen.org    http://www.erikhansen.org

__________________________________________________
Do you Yahoo!?
Yahoo! Tax Center - forms, calculators, tips, more
http://taxes.yahoo.com/



More information about the use-livecode mailing list