Another question about variables

Mike Bonner bonnmike at gmail.com
Sun May 1 09:34:53 EDT 2016


To see whats going on, do this..

on mouseUp
-- Local undeclared un-initialized variables evaluate as string values.
 myvar is "myvar"
-- so the value returned is the name of the variable Meaning the engine
doesn't see it as a variable
-- and sees it as a string.
   answer myVar



   put 1 into myArray[1]
   put 1 into myArray[2]


 -- 2 hitter here.  Initialized with values, and the brackets force the
engine to see this as an array variable.
-- Functions as you would expect
-- there is no value in element 3, but the engine sees it as a variable so
it will answer empty
   answer myArray[3]

-- this one, again has the brackets forcing the engine to recognize it as
an array variable so it will answer empty.
   answer myArray1[3]
end mouseUp

On Sun, May 1, 2016 at 7:15 AM, <jbv at souslelogo.com> wrote:

> Hello again,
>
> Please take a long at the following script :
>
> on mouseUp
>    if myVar is empty then
>       answer 1
>    else
>       answer 0
>    end if
>
>    put 1 into myArray[1]
>    put 1 into myArray[2]
>
>    if myArray[3] is empty then
>       answer 1
>    else
>       answer 0
>    end if
>
>    if myArray1[3] is empty then
>       answer 1
>    else
>       answer 0
>    end if
> end mouseUp
>
> Is there any logic explanation why it answers "0" for myVar
> and "1" for myArray and myArray1 ?
>
> Thanks
> jbv
>
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>



More information about the Use-livecode mailing list