comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Renaming a variable in IDL?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Renaming a variable in IDL? [message #55503] Fri, 24 August 2007 02:07
peterberg79 is currently offline  peterberg79
Messages: 2
Registered: August 2007
Junior Member
No Message Body
Re: Renaming a variable in IDL? [message #55504 is a reply to message #55503] Fri, 24 August 2007 01:38 Go to previous message
Foldy Lajos is currently offline  Foldy Lajos
Messages: 268
Registered: October 2001
Senior Member
On Fri, 24 Aug 2007, peterberg79@gmail.com wrote:

> Hi,
> I am writing a procedure for autmatically saving some variables from
> more advanced programs for easy access later on. Something along the
> lines of:
>
> PRO, SAVPRO, XVAR, Fname
> save, XVAR, filename=Fname
> end
>
> So if I want to save the file 'YVAR' to filename 'YVAR.sav' I would
> call:
> SAVPRO, YVAR, 'YVAR.sav'
> The problem is that in the save file the variable would be called XVAR
> instead of YVAR, which is a problem for me.
> I realized that I can retrieve the original varaible name as a string
> and include it to the SAVPRO call. But then I got lost on how to
> rename a variable to a string name. I was thinking there might be
> soemthing along the lines of using echo in unix (echo
> $STRYVAR'=XVAR'), but I have found no such function.
>
> My question is: Is it possible to rename a variable in IDL
> automatically? Or is there a better way to do all this?
>
>

1. execute

2. (scope_varfetch('xvar', /enter))=temporary(yvar) moves the content of
yvar to xvar (yvar will be undefined).

regards,
lajos
Re: Renaming a variable in IDL? [message #55505 is a reply to message #55504] Fri, 24 August 2007 01:36 Go to previous message
Maarten[1] is currently offline  Maarten[1]
Messages: 176
Registered: November 2005
Senior Member
On Aug 24, 7:28 am, peterber...@gmail.com wrote:
> Hi,
> I am writing a procedure for autmatically saving some variables from
> more advanced programs for easy access later on. Something along the
> lines of:
>
> PRO, SAVPRO, XVAR, Fname
> save, XVAR, filename=Fname
> end
>
> So if I want to save the file 'YVAR' to filename 'YVAR.sav' I would
> call:
> SAVPRO, YVAR, 'YVAR.sav'
> The problem is that in the save file the variable would be called XVAR
> instead of YVAR, which is a problem for me.
> I realized that I can retrieve the original varaible name as a string
> and include it to the SAVPRO call. But then I got lost on how to
> rename a variable to a string name. I was thinking there might be
> soemthing along the lines of using echo in unix (echo
> $STRYVAR'=XVAR'), but I have found no such function.
>
> My question is: Is it possible to rename a variable in IDL
> automatically? Or is there a better way to do all this?

; restore into XVAR, varname is the string that contains the name to
be used
dum = EXECUTE(varname + " = XVAR")
undefine, XVAR

But there probably is a much better way (probably by not using save
files at all).

Maarten
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: read_ascii for more than one file
Next Topic: CHECKBOX default in ION

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 18:14:01 PDT 2025

Total time taken to generate the page: 0.00568 seconds