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.
Result = CDF_ATTEXISTS(
Attribute [, EntryNum]
The CDF ID of the file containing the
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
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
), but this is not required.
is a variable ID (as opposed to a variable name) and the variable is a zVariable, set this flag to indicate that the variable ID is a zVariable ID. The default is to assume that
is an rVariable ID. Note: the attribute must have a scope of VARIABLE_SCOPE.
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)
PRINT, EXISTS(cdfid, 1)
PRINT, EXISTS(cdfid, 'BAD ATTR')
Attribute Does Not Exist