Using a variable for an array name
Richard Gaskin
ambassador at fourthworld.com
Wed Feb 1 19:08:29 EST 2017
Peter Bogdanoff wrote:
> I have arrays:
> tArray1
> tArray2
> tArray3
> tArray4
>
> I want to get data from one of them:
>
> put “tArray” & “1” into tVar
> put tVar [“Text”] into tText1
>
> tText1 is empty.
>
> Is there a way to get the data from the arrays without doing this
> kind of thing for each array:
>
> put tArray1 [“Text”] into tText1
> put tArray2 [“Text”] into tText2
Whenever you have a collection of variables whose names may be variable,
an array is a natural fit.
LiveCode supports n-dimensional arrays, so you could use:
-- Store:
put "something" into tBigArray["1"]["text"]
put "somethingelse" into tBigArray["2"]["text"]
-- Retrieve:
put tBigArray["1"]["text"] into tSomeVar
put tBigArray["2"]["text"] into tAnotherVar
--
Richard Gaskin
Fourth World Systems
Software Design and Development for the Desktop, Mobile, and the Web
____________________________________________________________________
Ambassador at FourthWorld.com http://www.FourthWorld.com
More information about the use-livecode
mailing list