The CDF_ATTEXISTS function returns TRUE (1) if the specified attribute exists in the specified CDF file, or FALSE (0) if it does not exist. Attributes may be specified by name or number.
The CDF ID of the file containing the Attribute to be checked, returned from a previous call to CDF_OPEN or CDF_CREATE.
A string containing the name or zero-based attribute number of the attribute to be checked.
The entry number to confirm. If EntryNum is not specified, the entire file is searched for the specified attribute. If the attribute is variable in scope, this is either the name or number of the variable the attribute is to be associated with. If the attribute is global in scope, this is the actual gEntry. It is the user's responsibility to keep track of valid gEntry numbers. Normally gEntry numbers will begin with 0 or 1 and will increase up to MAXGENTRY (as reported in the GET_ATTR_INFO structure returned by CDF_CONTROL ), but this is not required.
Create a function to test an attribute's existance and return a string:
FUNCTION exists, cdfid, attname_or_number
IF CDF_ATTEXISTS(cdfid, attname_or_number) THEN $
RETURN,' Attribute Exists' ELSE $
RETURN,' Attribute Does Not Exist'
Create a CDF with 2 attributes:
cdfid = CDF_CREATE('DEMOattexists')
attr1_id = CDF_ATTCREATE(cdfid, 'GLOBAL_ATT' , /GLOBAL_SCOPE)
attr2_id = CDF_ATTCREATE(cdfid, 'VARIABLE_ATT', /VARIABLE_SCOPE)
Check the existance of the two attributes, plus a third that does not exist:
PRINT, EXISTS(cdfid, attr1_id)