Automatic Structure Definition
In versions of IDL prior to version 5, references to an undefined named structure would cause IDL to halt with an error. This behavior was changed in IDL version 5 to allow the automatic definition of named structures.
When IDL encounters a reference to an undefined named structure, it will automatically search the directories specified in !PATH for a procedure named Name__DEFINE, where Name is the actual name of the structure. If this procedure is found, IDL will call it, giving it the opportunity to define the structure. If the procedure does in fact define the named structure, IDL will proceed with the desired operation.
Note
There are two underscores in the name of the structure definition procedure.
For example, suppose that a structure named mystruct has not been defined, and that no procedure named mystruct__define.pro exists in the directories specified by !PATH. A call to the HELP procedure produces the following output:
IDL prints:
% Attempt to call undefined procedure/function:'MYSTRUCT__DEFINE'. % Structure type not defined: MYSTRUCT. % Execution halted at: $MAIN$
Suppose now that we define a procedure named mystruct__define.pro as follows, and place it in one of the directories specified by !PATH:
With this structure definition routine available, the call to HELP produces the following output:
IDL prints:
% Compiled module: MYSTRUCT__DEFINE. ** Structure MYSTRUCT, 2 tags, length=12: A FLOAT 0.00000 B STRING ''
Remember that the fields of a structure created by copying a named structure definition are filled with zeroes or null strings. Any structure created in this way—either via automatic structure definition or by explicitly creating a new structure from an existing structure—must be initialized to contain values after creation.