curious behavior...

Paul Kocsis pkocsis at cox.net
Fri May 28 10:25:46 EDT 2004


It is because numberFormat is a local property which gets reset when a
handler finishes, and using "do" is like a mini-one-line-handler...
consider the following slight variation of your handler:

on mouseUp
    --repeat 4 times
      --put "#" after t
    --end repeat
    put "|" into t
    put "set the itemDelimiter to " &quote& t &quote into tDo
    do tDo
    put the itemDelimiter
 end mouseUp

This puts a comma into the Message Box.  The itemDelimiter *is* set by "do"
(just like the numberFormat is), but then is reset immediately upon do's
completion and return to the handler that called it.  If we try a similar
experiment with a global property (a property that does NOT get reset when a
handler finishes) like relayerGroupedControls...something like:

on mouseUp
    --repeat 4 times
      --put "#" after t
    --end repeat
    put true into t
    put "set the relayerGroupedControls to " &quote& t &quote into tDo
    do tDo
    put the relayerGroupedControls
 end mouseUp

You will see that this does indeed put 'true' into the Message Box, because
the do (just like in your example) did indeed perform the set command, but
since the property was a global property and not a local one, upon do's
completion, it was NOT automatically reset.

Obviously, the following accomplishes the task of programmatically setting
the numberFormat....till mouseUp exits... ;)

on mouseUp
   repeat 4 times
     put "#" after t
   end repeat
   --put "set the numberFormat to " &quote& t &quote into tDo
   --do tDo
   set the numberFormat to t
   put 5+1
end mouseUp

Paul Kocsis

----- Original Message ----- 
From: "Chipp Walters" <chipp at chipp.com>
To: "Use-Revolution" <use-revolution at lists.runrev.com>; "tuviah snyder"
<tuviah at runrev.com>
Sent: Friday, May 28, 2004 7:19 AM
Subject: curious behavior...


> I'm trying to programatically set the numberFormat property.
>
> on mouseUp
>    repeat 4 times
>      put "#" after t
>    end repeat
>    put "set the numberFormat to " &quote& t &quote into tDo
>    do tDo
>    put 5+1
> end mouseUp
>
> puts just "6" in the msg
>
> now if I try:
>
> on mouseUp
>    set the numberFormat to "####"
>    put 5+1
> end mouseUp
>
> It puts the expected "0006"
>
> Any ideas why??
>
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/use-revolution



More information about the use-livecode mailing list