Script local variables

Peter Haworth pete at lcsql.com
Sun Feb 23 16:02:16 EST 2014


Sorry, hit send too soon.  Her's a more detailed version.

In a card script, I have

local sVar="xyz"

function getVar
   return sVar
end getVar

command changeVar
   put "abc" into sVar
end changeVar

In button A on the card, I have:

on mouseUp
   put getVar()
end mouseUp

In button B on the card, I have

on mouseUp
   changeVar
end mouseUp

I click button A and "xyz" appears in the message box.

I click button B, then button A and "abc" appears in the message box.  So
you can change the value of script local variables with values assigned in
this way.

Here's the interesting part.  I deliberately caused a script compile error
in the card script, corrected it, and recompiled, then clicked button B,
and "xyz" appeared in the message box.

So it appears that script compile errors don't wipe out the original value
assigned to a script local variable in this way, but not any subsequent
changes made to it.  I guess that makes sense because it seems like the
value is assigned to the script local variable every time a handler in the
script is executed.




Pete
lcSQL Software <http://www.lcsql.com>
Home of lcStackBrowser <http://www.lcsql.com/lcstackbrowser.html> and
SQLiteAdmin <http://www.lcsql.com/sqliteadmin.html>


On Sun, Feb 23, 2014 at 12:52 PM, Peter Haworth <pete at lcsql.com> wrote:

>
> On Sun, Feb 23, 2014 at 11:14 AM, J. Landman Gay <jacque at hyperactivesw.com
> > wrote:
>
>> I haven't tried it yet, maybe someone else can confirm.
>
>
> Yes, you can change the value of a script local variable in the way you
> described
>
> What's really interesting though is that the value of a script local
> variable assigned in this way is NOt wiped out by a script compile error.It
> feels like the value is assigned to the variable each and every time a
> handler in the script is executed.
>
>
>
> Pete
> lcSQL Software <http://www.lcsql.com>
> Home of lcStackBrowser <http://www.lcsql.com/lcstackbrowser.html> and
> SQLiteAdmin <http://www.lcsql.com/sqliteadmin.html>
>



More information about the use-livecode mailing list