having a routine .compile something? [message #47734] |
Wed, 22 February 2006 07:57  |
mmiller3
Messages: 81 Registered: January 2002
|
Member |
|
|
Dear IDL gang,
I've written some code that saves some configuration information
by writing the IDL code needed to recreate it. For example, to
create some object instances, I call it's IDL_code method and
save the results to a text file. This file contains lines like
foo = OBJ_NEW('my_thing', args)
foo->set_param1, value
foo->set_param2, another_value
The idea is that I can recreate the object later on by reading
each line in that text file and EXECUTE'ing it. I like this
better than a save file becuase I can go and edit the saved file
easily . But now I want to go and add multi-line commands to my
saved file, like loops and such. Then I cannot use EXECUTE to
execute these commands, so I'm looking at CALL_PROCEDURE. I can
easily have my objects save a procedure, instead of a series of
single line commands. Then when I read the file, I can find the
procedure name and CALL_PROCEDURE on it. So my question is, is
there a way to .compile the contents of a file from within a
procudure or function call, so that I can CALL_PROCEDURE it?
I suspect that there is no way to do that, so I'm wondering if
anyone has suggestions for a work around. I suppose I can create
a unique procudure name and corresponding file name. Put a "PRO
unique_name, args" at the head of that file, append the contents
of my saved IDL commands, append an end, and then do a
"CALL_PROCEDURE, unique_name, args", which, as long as my
unique_name.pro file is in the IDL_PATH, will run my procesure.
Any comments or suggestions?
Mike
--
Michael A. Miller mmiller3@iupui.edu
Imaging Sciences, Department of Radiology, IU School of Medicine
|
|
|
Re: having a routine .compile something? [message #48145 is a reply to message #47734] |
Sat, 01 April 2006 01:32  |
Michael Galloy
Messages: 1114 Registered: April 2006
|
Senior Member |
|
|
Michael A. Miller wrote:
> Dear IDL gang,
>
> I've written some code that saves some configuration information
> by writing the IDL code needed to recreate it. For example, to
> create some object instances, I call it's IDL_code method and
> save the results to a text file. This file contains lines like
>
> foo = OBJ_NEW('my_thing', args)
> foo->set_param1, value
> foo->set_param2, another_value
>
> The idea is that I can recreate the object later on by reading
> each line in that text file and EXECUTE'ing it. I like this
> better than a save file becuase I can go and edit the saved file
> easily . But now I want to go and add multi-line commands to my
> saved file, like loops and such. Then I cannot use EXECUTE to
> execute these commands, so I'm looking at CALL_PROCEDURE. I can
> easily have my objects save a procedure, instead of a series of
> single line commands. Then when I read the file, I can find the
> procedure name and CALL_PROCEDURE on it. So my question is, is
> there a way to .compile the contents of a file from within a
> procudure or function call, so that I can CALL_PROCEDURE it?
Yes, RESOLVE_ROUTINE will do it. Specifiy the name of the routine as an
argument and RESOLVE_ROUTINE will (re)compile it.
-Mike
|
|
|