Re: converting a string to an IDL command [message #62380 is a reply to message #62377] |
Mon, 08 September 2008 12:29   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Mark writes:
> Actually, I have a related question, for which if it's obvious I
> apologize in advance.
>
> Not sure how to put this precisely, but....
>
> Let's say I have an array called "happydays".
>
> I'd like to make a function that would take the string 'happydays',
> and say, return the min and max of the array with that name:
>
> out=some_function('happydays')
> where out is the string:
>
> 'The max and min of HAPPYDAYS is 0 and 15"
>
>
> Just as well, would be something like:
>
> out=some_function(happydays)
> and out is the same string as above.
>
> In other words, I guess what I'm asking is, is there a way to find
> the original name of a variable that was passed to a sub-program or a
> function....
Now you are going down a really slippery slope. Better be
careful!
Think about it. You are inside of SOME_FUNCTION and you need
to know something about a variable array named "happydays".
Where is this array? Not inside the function where you are
thinking about it, that's for sure. Could you find it anyway?
Maybe, if you knew where to look. But where would that be?
One level up? Unlikely. Because if it were there, the person
who called you could have just as easily called the MINMAX command on
the array itself. Why didn't he? Maybe he didn't know where it was
either. Are you going to look for the data array everywhere? Where
*is* everywhere, anyway?
Anyway, if you think this is worth pursuing (I don't), then have
a look at the SCOPE_VAR** routines. They are what you want to use to
nose around in places you have no business being.
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
|
|
|