Mystery with arrays (lost key)

Dave Cragg dcragg at lacscentre.co.uk
Wed Apr 10 05:22:00 EDT 2002


At 7:11 pm -0400 9/4/02, andu wrote:
>In this case test2 is still a variable but it also has a value and
>keys() returns the correct number of keys. Having to quote or not a
>variable name depending on it having a value is not exactly the Metacard
>I use to know ;-).

Don't you have this the wrong way round? :)

Going back to the original example in this thread ....
>on mouseUp
>   IF 1=2 THEN
>     put  1 into test2
>   else
>     put 55 into  GrandTotals[test1]
>     put 66 into GrandTotals[test2]
>     put 22 into  GrandTotals[test3]
>   end if
>
>   put keys (GrandTotals)
>end mouseUp

The poster (T.G.) seemed surprised that test2 wasn't a valid key. I 
think the bigger surprise should be that test1 and test3 are valid 
keys. The standard way to use literals is to quote them. The fact 
that Metacard let's us get away without quoting literals if there is 
no variable with the same name isn't a good reason to do it that way. 
For our sanity, we should probably always presume the following two 
statements will produce different results.

put 66 into GrandTotals[test2]
put 66 into GrandTotals["test2"]

Cheers
Dave Cragg



More information about the metacard mailing list