If you distribute programs that call IDL with a runtime license or a buffer license, use IDL_RuntimeExec(). After initialization IDL_RuntimeExec() can be used to run self-contained IDL applications from a Save/Restore file. IDL_RuntimeExec() restores the file, then attempts to call an IDL procedure named MAIN. If no MAIN procedure is found, the function attempts to call a procedure with the same name as the restored Save file. (That is, if the Save file is named myprog.sav, IDL_RuntimeExec() looks for a procedure named myprog.)

Note: IDL_RuntimeExec() clears the value of the !ERROR_STATE system variable before it restores the specified Save file.

IDL_RuntimeExec() returns the value of the !ERROR_STATE.CODE system variable after IDL attempts to restore the specified file and execute the MAIN or named procedure. Thus, a return value of zero indicates that the specified Save file was restored and the appropriate procedure executed without error.

int IDL_RuntimeExec(char *file);


file is the complete path specification to the Save file to be restored, in the native syntax of the platform in use.

Checking the Error Status

If the return value from IDL_RuntimeExec() is not zero, you may wish to check the values of other fields in the !ERROR_STATE structure. The following code fragment populates buffer with the values of the !ERROR_STATE.MSG, !ERROR_STATE.SYS_MSG, and !ERROR_STATE.CODE system variable fields:

sprintf(buffer, "error_state.msg: %s\nerror_state.sys_msg:
%s\nerror_state: %d\n",