Wrapper Routines
CALL_EXTERNAL routines are very sensitive to the number and type of the arguments they receive. Calling a CALL_EXTERNAL routine with the wrong number of arguments or with arguments of the wrong type can cause IDL to crash. For this reason, it is a good practice to provide an IDL wrapper routine that is used to make the actual CALL_EXTERNAL call. The job of this wrapper, which is written in the IDL language, is to ensure that the arguments that are passed to the external code are always of the correct number and type. The following IDL procedure is the wrapper used in the simple_vars() example of the previous section (Example: Passing Parameters by Reference to IDL).
Example Code
This file, simple_vars.pro, is located in the external/call_external/C subdirectory of the IDL installation directory.
.
The routine simple_vars.pro uses the system routine SIZE() to examine the arguments that are passed in by the user to the simple_vars routine. If one of the arguments is undefined, a default value will be used in the call to the external routine. Otherwise, the argument will be converted to a scalar of the appropriate type.
Note
GET_CALLEXT_EXLIB() is a function provided with the CALL_EXTERNAL examples; it builds the necessary sharable library of external C code and returns the path to the library as its result.