Okay I just did a simple test. Given: local sVar = "abc"
on mouseUp breakpoint put sVar put "abc" into bVar put "123" into sVar end mouseUp With Variable Preservation turned on, the first time through I get “abc” in the message box. The second time through I get “123” in the message box as you would expect. I then make a script edit and recompile. The next time I get “abc” in the message box, definitively proving that recompiling DOES in fact re-initialize the local variable WITH Variable Preservation turned on! Now I change the first line to read: local sVar and the turn variable preservation off. I make a script edit the variable resets. If I turn on variable preservation it does not. So it appears that pre-loading a value into a script local variable TRUMPS variable preservation, in the sense that the recompile will ALWAYS reinitialize the script local variable at compile time. HTH Bob On Feb 23, 2014, at 13:02 , Peter Haworth <p...@lcsql.com> wrote: > 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 <p...@lcsql.com> wrote: > >> >> On Sun, Feb 23, 2014 at 11:14 AM, J. Landman Gay <jac...@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> >> > _______________________________________________ > use-livecode mailing list > use-livecode@lists.runrev.com > Please visit this url to subscribe, unsubscribe and manage your subscription > preferences: > http://lists.runrev.com/mailman/listinfo/use-livecode _______________________________________________ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode