ARG_PRESENT function returns a nonzero value if the following conditions are met:
The argument to ARG_PRESENT was passed as a plain or keyword
argument to the current routine by its caller, and
The argument to ARG_PRESENT is a named variable into which a value will be copied when the current routine exits.
In other words, ARG_PRESENT returns TRUE if the value of the specified variable will be passed back to the caller. This function is useful in user-written procedures that need to know if the lifetime of a value they are creating extends beyond the current routine's lifetime. This can be important for two reasons:
To avoid expensive computations that the caller is not interested in.
To prevent heap variable leakage that would result if the routine creates pointers or object references and assigns them to arguments that are
passed back to the caller.
Result = ARG_PRESENT(
The variable to be tested.
Suppose that you are writing an IDL procedure that has the following procedure definition line:
PRO myproc, RET_PTR = ret_ptr
The intent of the RET_PTR keyword is to pass back a pointer to a new pointer heap variable. The following command could be used to avoid creating (and possibly losing) a pointer if no named variable is provided by the caller:
IF ARG_PRESENT(ret_ptr) THEN BEGIN
The commands that follow would only be executed if
is supplied and will be copied into a variable in the scope of the calling routine.