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

Re: Accessing "main" level variables

Craig Markwardt wrote:

>Incidentally, there is an internal IDL routine which *can* do this.
>Unfortunately you need to write a DLM to access it.

I haven't worked with the internal IDL routines, and don't plan to. But I did look at the EDG documentation,
and it seems like it would be relatively straighforward to write a toolbox  that would allow us (the IDL user community) to access main level variables from within procedures. For instance, an IDL shell could
be written to access the routine

                             IDL_VPTR IDL_GetVarAddr(char *name)

which would return the address of the variable, and then the variable could be obtained and returned as the return value of the function.

Has anyone written such a toolbox?

Craig Markwardt wrote:

Michael Lefsky <lefsky@home.com> writes:

> 2) Is it possible to access main level variables from within a procedure?
> For instance, to solve the problem outlined in 1), you could simply
> write a procedure called "save" which would have precedence over the
> system command save. However, once in the procedure "save", you would no
> longer have access to the main level variables that you want to save.
> Even if you specified them as arguments to "save" you would no longer
> have access to their original (ie. main level) names. There are numerous
> applications for which I would like to be able to somehow get either )
> the names of the variables passed to the current procedure (ie. the
> names they had at the level above them) or to access the main level
> variables. Of course there might be numerous ways to do either of these
> things, from the ugly to the sublime- personally, I am not particular.

I like your questino.  I know I will get flamed for saying it, but I
think there are some times when it is desireable for a program to
deposit its results into the main level.  For example, a fully canned
curve fitting program may want to return the fitting results.  This
should of course be done with full control and permission of the user.

"Why," you ask, "don't you just return it as a regular or keyword

"Simple," I say.  "You don't always know how many variables you are
going to return."  Also, if it were a curve fitting program "for
dummies" then I would want to make it as simple as possible.

Incidentally, there is an internal IDL routine which *can* do this.
Unfortunately you need to write a DLM to access it.


Craig B. Markwardt, Ph.D.         EMAIL:    craigmnet@cow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response

Michael Lefsky, PhD
Research Ecologist
U.S. Forest Service
Forest Sciences Laboratory
Corvallis, OR