NAME:
CHKSTRU (function)
PURPOSE:
check validity of a structure and test if necessary
fields are contained
CATEGORY:
tools
CALLING SEQUENCE:
res=CHKSTRU(STRUCTURE,FIELDS [,/VERBOSE])
INPUTS:
STRUCTURE --> the structure to be tested. If STRUCTURE is
not of type structure, the function will return 0
FIELDS --> a string or string array with field names to
be contained in STRUCTURE. CHKSTRU returns 1 (true)
only if all field names are contained in STRUCTURE.
The entries of FIELDS may be upper or lowercase.
KEYWORD PARAMETERS:
INDEX --> a named variable that will contain the indices of
the required field names in the structure. They can then
be assessed through structure.(index(i)) . Index will
contain -1 for all fields entries that are not in the
structure.
/VERBOSE --> set this keyword to return an error message
in case of an error.
/EXTRACT --> set this keyword to extract a fields from the
structure. -1 is return is fields or structure. are
incorrect.
OUTPUTS:
CHKSTRU returns 1 if successful, otherwise 0.
SUBROUTINES:
REQUIREMENTS:
NOTES:
EXAMPLE:
test = { a:1, b:2, c:3 }
required = ['a','c']
if CHKSTRU(test,required) then print,'found a and c.'
IDL> print, CHKSTRU(test,'b')
1
IDL> print, CHKSTRU(test,'b',/extract)
2
MODIFICATION HISTORY:
mgs, 02 Mar 1998: VERSION 1.00
mgs, 07 Apr 1998: - second parameter (FIELDS) now optional