Re: name a variable with number [message #87454 is a reply to message #87453] |
Tue, 04 February 2014 05:57   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
rjp23@le.ac.uk writes:
> This is probably a "bad" way of doing it but I often use "execute" to generate variable names dynamically based on the contents of other variables which I think sounds like what you want to do.
>
> For example:
>
> for j=0, 24 do blah=execute('n'+strtrim(j,2)+'=nn[*,j]')
>
> This will create the 25 arrays named n0, n1, n2, etc that contain nn[0,*], etc.
>
> I'd be interested in what David et al. this of this as I end up using it quite often (but in more complicated situations).
I think in the hands of someone who knows what they are doing this can
be a powerful programming technique. I rarely see it used in those kind
of hands. :-)
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.")
|
|
|