Re: name a variable with number [message #87465 is a reply to message #87464] |
Tue, 04 February 2014 11:51   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
rjp23@le.ac.uk writes:
> How I use it is slightly different to the OP, maybe hence the confusion. I don't so much use it to split up data but to treat data from various sources the same way. It's pretty much the opposite of having hard-coded variable names.
>
> e.g. It's normally when I have data in the same format from various different sources (usually different model runs) which I want to do the same thing to. Rather than have a chunk of code for each data source, to do the same thing to modelA, modelB, modelC, etc I just use execute to make thisModel=modelA within a loop and then act on each in turn.
>
> That probably doesn't make any more sense though ;-)
Well, not to me, it doesn't. ;-)
In a loop like this, when I want clarity, I usually do something like
this. Is this what you mean?
FOR j=0,n DO BEGIN
thisModel = theModels[j]
DoSomethingWith, thisModel
....
ENDFOR
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
|
|
|