Re: Using a variable for an array name
Peter: FYI multi-dimensional arrays are awesome. I use to be "scared" of them, but in RevIgniter we have all kinds of things like galleriaShow["options"]["width"]["805] and even more… so I had go understand it. And, on top of this you can have an array "inside" a key/value (where the value is an array) Once you wrap your head around this you will never look back! BR ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Using a variable for an array name
OK, I’ll test the two methods when I get the general procedure working. > On Feb 1, 2017, at 7:52 PM, Richard Gaskin via use-livecode >wrote: > > Peter Bogdanoff wrote: > > > Richard, I’ve heard that “do” is slow because it must be compiled > > every time. I am reiterating this possibly hundreds of times, so > > it is probably much better to combine the arrays into a Big Array? > > It'll be a little faster, and to my eye much more readable. > > "Do" is a good option when no other option exists. :) > > -- > Richard Gaskin > Fourth World Systems > Software Design and Development for the Desktop, Mobile, and the Web > > ambassa...@fourthworld.comhttp://www.FourthWorld.com > > ___ > use-livecode mailing list > use-livecode@lists.runrev.com > Please visit this url to subscribe, unsubscribe and manage your subscription > preferences: > http://lists.runrev.com/mailman/listinfo/use-livecode ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Using a variable for an array name
Peter Bogdanoff wrote: > Richard, I’ve heard that “do” is slow because it must be compiled > every time. I am reiterating this possibly hundreds of times, so > it is probably much better to combine the arrays into a Big Array? It'll be a little faster, and to my eye much more readable. "Do" is a good option when no other option exists. :) -- Richard Gaskin Fourth World Systems Software Design and Development for the Desktop, Mobile, and the Web ambassa...@fourthworld.comhttp://www.FourthWorld.com ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Using a variable for an array name
Yes, “do” does it. Thank you Ralph and Bob. Richard, I’ve heard that “do” is slow because it must be compiled every time. I am reiterating this possibly hundreds of times, so it is probably much better to combine the arrays into a Big Array? Peter > On Feb 1, 2017, at 7:16 PM, Bob Sneidar via use-livecode >wrote: > > Even better! > > Bob S > > > On Feb 1, 2017, at 16:08 , Richard Gaskin via use-livecode > > wrote: > > 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 > > ___ > use-livecode mailing list > use-livecode@lists.runrev.com > Please visit this url to subscribe, unsubscribe and manage your subscription > preferences: > http://lists.runrev.com/mailman/listinfo/use-livecode ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Using a variable for an array name
Even better! Bob S On Feb 1, 2017, at 16:08 , Richard Gaskin via use-livecode> wrote: 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 ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Using a variable for an array name
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 ambassa...@fourthworld.comhttp://www.FourthWorld.com ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Using a variable for an array name
This is called macro substitution in other languages. You would use the form array in Foxpro for instance. LC has no macro Substitution. Instead: put "put tArray" & tVar & "[temp] into tText" & tVar into tCommand replace "temp" with quote & "text" & quote in tCommand do tCommand (untested) bob s On Feb 1, 2017, at 15:13 , Peter Bogdanoff via use-livecode> 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 Thanks! Peter Bogdanoff ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
RE: Using a variable for an array name
"Do" will do the trick. Repeat with tVarNum = 1 to 4 do "put"&&"["("Text")&"] into tText" do "put"&&"["("SomeOtherArrayValue")&"] into tSomeOtherArrayValue" end repeat function WrapQ pString return quote end WrapQ Ralph DiMola IT Director Evergreen Information Services rdim...@evergreeninfo.net -Original Message- From: use-livecode [mailto:use-livecode-boun...@lists.runrev.com] On Behalf Of Peter Bogdanoff via use-livecode Sent: Wednesday, February 01, 2017 6:14 PM To: How to use LiveCode Cc: Peter Bogdanoff Subject: Using a variable for an array name 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 Thanks! Peter Bogdanoff ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode