Re: Restoring Data within a Procedure [message #8555] |
Fri, 04 April 1997 00:00 |
Marty Ryba
Messages: 16 Registered: May 1996
|
Junior Member |
|
|
D.H.Brooks wrote:
> I have a widget that I use to select IDL save/restore files and so when I pick
> one I'm within a compound widget at a lower level than the main program. This means
> that I get the message;
>
> % Identifiers can only be added or deleted at the main level: STRUCTURE.
>
> How would I go about getting rid of this? Can anyone help?
The key is that you cannot *add* variables within a compiled
procedure. However, in IDL you can *always* change the size/type of any
already-declared variable. So, if your SAVE/RESTORE files always have
the same variables (which I assume is the case since you are picking one
of several files for supposedly identical processing), you pre-declare
the variables.
Here's a simple example:
FUNCTION do_restore, filename
structure = 0 ; Creates identifier for variable within
; save/restore file
restore, filename
return, structure ; return to calling function
END
--
Dr. Marty Ryba | Of course nothing I say here is official
MIT Lincoln Laboratory | policy, and Laboratory affililaton is
ryba@ll.mit.edu | for identification purposes only,
| blah, blah, blah, ...
|
|
|