Over the years, there have been many requests to do "variable variables",
that is, to construct a variable name on the fly.
Invariably, the person asking the question is taking the seemingly obvious
solution to a problem, but usually what really signals is that it is time
to start learning about lists. I don't know what they're trying to do in
this particular case, but lists (and property lists) are suited for exactly
this sort of thing, with only a fraction of the overhead of recompositing
strings and doing on-the-fly parsing of commands.
- Tab
At 09:30 AM 5/24/01 -0400, Colin Holgate wrote:
>> >set a = "abc"
>>>set b = "xyz"
>>>set abcxyz = "hello"
>>
>>Gosh, please don't do do in your code.
>>
>>(the globals)[#gNewGlobal] = "clean way to create a global"
>>--
>
>Where's the fun in that!
>
>Seriously though, if you don't know the name of the global (I know this is
>a stretch, but just for interest), can you do this?:
>
>(the globals)[symbol("myvariables" & nextvar)] = "some stuff"
>
>where nextvar might be an integer? Actually, I just tried it, and it does
>work. The above line would give you a new variable called myvariables1 (or
>whatever nextvar appends), and it does contain the text "some stuff".
>
>
>[To remove yourself from this list, or to change to digest mode, go to
>http://www.penworks.com/LUJ/lingo-l.cgi To post messages to the list,
>email [EMAIL PROTECTED] (Problems, email [EMAIL PROTECTED])
>Lingo-L is for learning and helping with programming Lingo. Thanks!]
>
[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/LUJ/lingo-l.cgi To post messages to the list,
email [EMAIL PROTECTED] (Problems, email [EMAIL PROTECTED])
Lingo-L is for learning and helping with programming Lingo. Thanks!]