Pointer Validity
Use the PTR_VALID function to verify that one or more pointer variables point to valid and currently existing heap variables, or to create an array of pointers to existing heap variables. If supplied with a single pointer as its argument, PTR_VALID returns TRUE (1) if the pointer argument points at a valid heap variable, or FALSE (0) otherwise. If supplied with an array of pointers, PTR_VALID returns an array of TRUE and FALSE values corresponding to the input array. If no argument is specified, PTR_VALID returns an array of pointers to all existing pointer heap variables. For example:
;Create a new pointer and heap variable. A = PTR_NEW(10) IF PTR_VALID(A) THEN PRINT, "A points to a valid heap variable." $ ELSE PRINT, "A does not point to a valid heap variable."
IDL prints:
For example:
;Destroy the heap variable. PTR_FREE, A IF PTR_VALID(A) THEN PRINT, "A points to a valid heap variable." $ ELSE PRINT, "A does not point to a valid heap variable."
IDL prints:
See "PTR_VALID" (IDL Reference Guide) for further details.