[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Creating Variables in Programs
- Subject: Re: Creating Variables in Programs
- From: Craig Markwardt <craigmnet(at)astrog.physics.wisc.edu>
- Date: 10 Jul 1998 09:51:41 -0500
- Newsgroups: comp.lang.idl-pvwave
- Organization: U. Wisc. Madison Physics -- Compact Objects
- References: <p.phillips-1007980758540001@es2.frc.utexas.edu><35A61707.41C6@io.harvard.edu>
- Reply-To: craigmnet(at)astrog.physics.wisc.edu
- Xref: news.doit.wisc.edu comp.lang.idl-pvwave:11487
Martin Schultz <mgs@io.harvard.edu> writes:
>
> Perry Phillips wrote:
> >
> > Does anyone know of a way to create a new array under program control, ie
> > create a string and use that string to make an array. As far as I can see
> > this is impossible in IDL?
> >
> > --
> > Perry Phillips p.phillips@mail.utexas.edu
>
>
> here's a quick example
>
>
> IDL> r=execute('a=fltarr(200)')
> IDL> help,a
> A FLOAT = Array[200]
>
There is a "gotcha." in the case of a compiled procedure, the
variable "a" must have already been defined. The following is usually
sufficient:
A = 0
...
R = EXECUTE('A=FLTARR(200)')
The IDL internal compiler needs to know that "A" exists before it can
be assigned to in an EXECUTE statement. The same applies for
restoring variables: all the variables in the SAVE file must be
predefined in the procedure. Assigning zero to them is fine.
Craig
--
--------------------------------------------------------------------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@astrog.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
--------------------------------------------------------------------------