script scope variables inexplicably becoming unset
J. Landman Gay
jacque at hyperactivesw.com
Tue Dec 30 13:59:05 EST 2014
On 12/30/2014 12:20 PM, Dr. Hawkins wrote:
> I am having problems with script scope variables (declared local before any
> handler) becoming unset, apparently within individual lines of handlers.
>
> For example, the code
> on shwChcStk
> ck "chstk: _" & chStk & "_; " & cr & chStk is empty
> if chStk is empty then
> --debug only; this happens in the debugger.
> answer "chStk empty"
> breakpoint
> initCtr
> end if
> if the chcStk of me then
> lock messages --chStk becomes unset during openstack!
> palette chStk
> unlock messages
> set the width of chStk to the width of chFld
>
> where ck is a logger:
>
> on ck stuff
> -- answer stuff
> -- breakpoint
> put stuff
> put stuff & cr after fld "log" of stack "ckwatch"
> end ck
>
> First it oddly produces simply "false" as the output, rather than
>
> _chStk_
> false
>
> If I comment out from &cr on it produces the first part.
>
> In any event, it can get to "if chStk" is empty with a value for chStk,
> open that stack as a pallete, and then have nothing in chStk or chFld two
> lines later.
>
> But this isn't entirely predictable, either--if I remove the lock messages
> around the palette command, ckStk gets emptied every time, even though
> there is nothing in the preOpenStack/OpenStack handlers executes other
> than logging of the milliseconds to a global, checks for whether it is
> the main stack, and an exit.
The semicolon has a special meaning and signifies the end of a script
statement when used in certain conditions. It looks like the engine is
trying to execute your literal. Try changing the semicolon to a
different character.
>
> And the weirdness continues.
>
> In another section
>
> ck the selectedChunk
>
> produced
> word 5 to 4 of field 11
>
> the next line,
>
> put the selectedChunk into pos
>
> put something like
> char 10000 to 100007 of field 1
>
> Is the put statement into the message box or another field (of a closed
> stack) changing the selectedChunk ???
The ck handler changes the field focus twice, once to the message box
and again to a logging field. The original selection is lost.
--
Jacqueline Landman Gay | jacque at hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
More information about the use-livecode
mailing list