[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Variable name to string



Thanks Craig.  That is just what I was looking for.  Running the program
at the main level is not a problem for me.  Basically, I have a bunch of
data stored in array's and saved in an IDL save file.  I just needed
something to convienently get them out of IDL and into individual text
files, while retaining the information contained in the array names.

Chad

On 18 Jul 2001, Craig Markwardt wrote:

> 
> Chad Bender <cbender@mail.astro.sunysb.edu> writes:
> 
> > Hello-
> > 
> > Can anyone please point me towards the solution of the following
> > problem?

> 
> This appears to be basic string manipulation, which can be
> accomplished using the "+" symbol.
> 
> ;; Get variable name.
> varname = ''
> read, varname
> 
> ;; Derive file name from variable name
> filename = varname + '.dat'
> 
> Now, as the others have pointed out, the harder question is really,
> how do you get at a variable for which you only have the name?
> EXECUTE can work if the variable and your code are at the same level.
> For example, this code
> 
> return_code = execute('DATA = '+varname)
> 
> will put the data into a variable named DATA.  Also, sneaky use of
> ROUTINE_NAMES can do it.  But honestly, you should try to re-work your
> concept so you don't have to do that if you can.
> 
> Craig
> 
> 
> -- 
> --------------------------------------------------------------------------
> Craig B. Markwardt, Ph.D.         EMAIL:    craigmnet@cow.physics.wisc.edu
> Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
> --------------------------------------------------------------------------
> 
>