XIASTREC
Name
XIASTREC
Purpose
XIASTREC Is A Structure Tag Recursive Existence Checker
Category
Structures, utility, recursion
Calling Sequence
result = XIASTREC( struct, tag_list )
Inputs
Struct: A structure
Optional Inputs
tag_list: A string array that contains the tags, subtags,
subsubtags, etc. whos existence you wish to verify
Keyword Parameters
DEBUG: Print some debug info
Outputs
This function returns 1 if the struct, or struct.tag, or
struct.tag.tag.tag... exists, and 0 if it does not. It returns -1
if called incorrectly.
Procedure
1. Check if the struct is valid
2. Check if tags were passed in. If so, does tag[0] exist in struct?
3. Recurse, checking if tag[1] exist in the struct that is tag[0].
Example
PRINT, XIASTREC( foo ) ; 0, foo not defined
PRINT, XIASTREC( !P, 'thick' ) ; 1, !P.THICK exists
x = { foo:{bar:42}, baz:'Goodbye Crue World' }
PRINT, XIASTREC( x, 'bar' ) ; 1, x.bar exists
PRINT, XIASTREC( x, ['foo', 'baz'] ) ; 0, x.foo.baz does not exist
PRINT, XIASTREC( x, ['foo', 'bar' ] ) ; 1, x.foo.bar exists
PRINT, XIASTREC( x, ['foo', 'bar', '42' ] ) ; 0, bar=42, not bar.42
Modification History
Written by: KDM, 2007-07-15