Storing Scalar Values
The IDL_StoreScalar() function sets an IDL_VARIABLE to a scalar value:
where:
dest
An IDL_VPTR to the IDL_VARIABLE in which the scalar should be stored.
type
The type code for the scalar value. See Type Codes.
value
The address of the IDL_ALLTYPES union that contains the value to store.
If dest is a location that cannot be stored into (for example, a temporary variable, constant, and so on), an error is issued and control returns to the interpreter. Otherwise, any dynamic part of dest is freed and value is stored into it.
The IDL_StoreScalarZero() function is a specialized variation of IDL_StoreScalar(). It stores a zero scalar value of any specified type into the specified variable:
where:
dest
An IDL_VPTR to the IDL_VARIABLE in which the scalar zero should be stored.
type
The type code for the scalar zero value. See Type Codes.
Using IDL_StoreScalar() to Free Dynamic Resources
In addition to performing its primary function, IDL_StoreScalar() and IDL_StoreScalarZero() have two very useful side effects:
Often, a system routine accepts an input argument that will have a new value assigned to it before the routine returns to its caller, and the initial value of that argument is of no interest to the routine. Storing a scalar value into such an argument at the start of the routine will automatically check it for storability and free unnecessary dynamic memory. In one easy operation, the required error checking is done, and you've improved the dynamic memory behavior of the IDL system by minimizing dynamic memory fragmentation. For example:
Error handling is discussed further in IDL Internals: Error Handling.