CDF_ATTEXISTS

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.

Calling Sequence

Result = CDF_ATTEXISTS( Id , Attribute [, EntryNum] )

Arguments

Id

The CDF ID of the file containing the Attribute to be checked, returned from a previous call to CDF_OPEN or CDF_CREATE.

Attribute

A string containing the name or zero-based attribute number of the attribute to be checked.

EntryNum

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.

Keywords

ZVARIABLE

If EntryNum 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 EntryNum is an rVariable ID. Note: the attribute must have a scope of VARIABLE_SCOPE.

Example

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'

END

 

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)

IDL prints:

Attribute Exists

PRINT, EXISTS(cdfid, 1)

IDL prints:

Attribute Exists

PRINT, EXISTS(cdfid, 'BAD ATTR')

IDL prints:

Attribute Does Not Exist

CDF_DELETE, cdfid

See Also

CDF_ATTCREATE , CDF_ATTGET , CDF_ATTDELETE , CDF_ATTINQ , CDF_ATTPUT , CDF_ATTRENAME