Re: using of EXECUTE??? [message #7363 is a reply to message #7351] |
Fri, 08 November 1996 00:00  |
davidf
Messages: 2866 Registered: September 1996
|
Senior Member |
|
|
Hendrik Roepcke <alpha@jungle.toppoint.de) writes:
> some people of this group warned me [not?] to use
> the IDL option: EXECUTE("???")
Who in the world are you talking to Hendrik? Nobody
on this group would *ever* say such a thing!
> It will mess up the memory-management of IDL
> after a while they estimated...
They don't know what they are talking about. :-)
> But this option is wunderfull for dynamical
> management of data-array!!
>
> EXECUTE(name_of_array+"=findgen("+string(dim_of_array)+") ")
You bet!
> shall I use execute or not?
Sure, use it! It's powerful. It's fun. And it will prove to your
friends that you are a *real* IDL programmer!
> any hints?
Well, your friends probably used it to create variables in a loop
and had a lot of problems which caused them to warn you off.
Don't get so carried away with EXECUTE that you start using
it for everything. For example, used inside an IDL procedure
or function, you can't create variables or symbols that don't
already exist there. (Kind of like what you are doing above.)
If the variable "name_of_array" doesn't exist in your
IDL program where you are doing this EXECUTE, you
will not be able to execute this statement more
than 2-3 times before something bad happens.
You can fix your code, by doing something like this:
name_of_array = 0
ok=EXECUTE(name_of_array+"=findgen("+string(dim_of_array)+ ")")
Now you can execute the EXECUTE statement as many times
as you like and you will never have any trouble with it. (At
least none that might be described as "messing up memory
management".)
By the way, I hear that the limitation on creating variables
like this will be going away in the next version of IDL.
And--I hope--so too will a limitation that the string you
pass to EXECUTE can only have 131 characters in it.
Why 131? You don't want to know! And I couldn't tell you in
any case. It's one of the weird things about IDL that causes
me to love it so. (By the way, this is the secret password to
the "IDL Expert Programmers" convention, held every year
in Boulder. They ask the question: "How many characters
in EXECUTE?" and if you answer "131" you get in. Please
don't tell them you heard it from me.)
One other hint. EXECUTE and its cousins CALL_PROCEDURE
and CALL_FUNCTION are dynamite in widget programs.
*Especially* if you want re-sizeable graphics windows.
Have fun!
David
*************************************************
* David Fanning, Ph.D.
* 2642 Bradbury Court, Fort Collins, CO 80521
* Phone: 970-221-0438 Fax: 970-221-4762
* E-Mail: davidf@dfanning.com
*
* Sometimes I go about pitying myself, and all along my
* soul is being blown by great winds across the sky.
* -- Ojibway saying
************************************************
|
|
|