IDL

ARG_PRESENT

ARG_PRESENT

The ARG_PRESENT 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:

  1. To avoid expensive computations that the caller is not interested in.
  2. To prevent heap variable leakage that would result if the routine creates pointers or object references and assigns them to arguments that are not passed back to the caller.

Example


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 ret_ptr is supplied and will be copied into a variable in the scope of the calling routine.

Syntax


Result = ARG_PRESENT(Variable)

Return Value


Returns a nonzero value if the following conditions are met:

  • The argument to ARG_PRESENT was passed as a plain argument or keyword 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.

Arguments


Variable

The variable to be tested.

Version History


5.0

Introduced

See Also


KEYWORD_SET, N_ELEMENTS, N_PARAMS

Notes


This page has no user notes yet. Be the first one!


This information is not subject to the controls of the International Traffic in Arms Regulations (ITAR) or the Export Administration Regulations (EAR). However, it may be restricted from transfer to various embargoed countries under U.S. laws and regulations.
© 2014 Exelis Visual Information Solutions