Mystery with arrays (lost key)

andu undo at cloud9.net
Thu Apr 11 00:56:01 EDT 2002


Tariel Gogoberidze wrote:
> 
> > From: Dave Cragg <dcragg at lacscentre.co.uk>
> > Subject: Re: Mystery with arrays (lost key)
> 
> > >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
> 
> Actually, I was little surprised that variable test2  was  processed in
> this if/else control  structure.
> 
> on mouseup
>   if 1=2 then
>       put 1 into atest
>   end if
>    if atest is an integer then beep
> end mouseup
> 
> no beep of course
> 
> I expected  the similar behavior in example with  arrays.
> 
> Additionally, what  bothered me  is that if variable test2  WAS executed
> then why put key() returned  empty and  not it's value = 1 as in Andu's example
> 
> on mouseUp
>     put  1 into test2
>     put 55 into  GrandTotals[test1]
>     put 66 into GrandTotals[test2]
>     put 22 into  GrandTotals[test3]
> end if
> 
>   put keys (GrandTotals)
> 
>   -- returns
>   --
>   1
>   test1
>   test3
>   -
> end mouseUp

Apparently test2 WAS executed or rather initialized the moment you
considered putting something into it (if 1=2 then put 1 into test2) for
which reason it's value became empty. As was mentioned, the only sane
solution is to eliminate the dual purpose quality of words as being a
variable if given a value or a literal if not -- in this example above,
test1 and test3 would be empty which I think would be less of a surprise
and should generate an error.
 
> 
> Best regards
> Tariel Gogoberidze
> _______________________________________________
> metacard mailing list
> metacard at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/metacard

-- 
____________________
Regards, Andu Novac



More information about the metacard mailing list