Re: name a variable with number [message #87460 is a reply to message #87459] |
Tue, 04 February 2014 10:00   |
Fabzi
Messages: 305 Registered: July 2010
|
Senior Member |
|
|
On 04.02.2014 18:28, rjp23@le.ac.uk wrote:
> Is there a better (generic) way of doing this?
I am not an expert enough, but if you are using a loop to generate
variables dynamically, and then using a loop again somewhere else to
read them, then you use the variables as "data holder" and this "data
holder" could be anything else. You have created a variable
modelB_variableA, what do you do with it afterwards? How do you check
later in your code that ModelX_VariableY is available to continue
processing?
This is much easier to test if you have a variable, say, ModelVar as a
pointer array and check if ModelVar[X,Y] is a valid pointer, for example.
For the problem you describe, HASH() in IDL 8+ could quite adapted. For
earlier versions, I guess a solution based on structures and/or pointers
could work.
There is nothing "wrong" in generating variables dynamically, it just
makes code difficult to understand and to debug. If you have something
that works, it's probably not necessary to change your code now, I guess...
|
|
|