array: why does this not work?

Ken Ray kray at sonsothunder.com
Mon Dec 2 02:13:00 EST 2002


Oliver,

It's because your incoming variable can't be immediately resolved as an
array. You need to use "do" to put it togethre before returning the result:

local myArray

on mouseUp
  put 100 into myArray["test"]
  answer getArray("myArray","test")
end mouseUp

function getArray pArray,pKey
  do "put " & pArray & "[" & pKey & "] into temp"
  return temp
end getArray


Note the "local myArray" - in order for the "getArray" function to "know"
about the myArray array, it needs to be available to it either as a declared
"script local" or global variable.

Hope this helps,

Ken Ray
Sons of Thunder Software
Email: kray at sonsothunder.com
Web Site: http://www.sonsothunder.com/


----- Original Message -----
From: "Oliver Hardt" <hardt at u.arizona.edu>
To: <use-revolution at lists.runrev.com>
Sent: Monday, December 02, 2002 12:50 AM
Subject: array: why does this not work?


> hello:  i have the following function that basically replaces get
> theArray[theKey];  put it.
>
> function gF_getA pArray, pKey
>    get pArray[pKey]
>    return it
> end gF_getA
>
>
> however, this function doesn't return anything, although the array
> contains the correct values.
>
> alternatively, i tried the following code with no positive result:
>
> function gF_getA pArray, pKey
>    get pArray[quote & pKey & quote]
>    return it
> end gF_getA
>
>
>
> thank you for your help!  best, olli.
> _______________________________________________
> 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