CDF_VARDELETE

The CDF_VARDELETE procedure deletes a variable from a SINGLE_FILE CDF file. Note that the variable's entries are also deleted, and that the variables which numerically follow the deleted variable within the CDF file are automatically renumbered. CDF rVariables and zVariables are counted separately within CDF files. Attempting to delete a variable from a MULTI_FILE format CDF file will result in an warning message.

Calling Sequence

CDF_VARDELETE,Id,Variable

Arguments

ID

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

VARIABLE

A string containing the name of the variable to be deleted OR the variable number to be deleted. Variable numbers are 0-based in IDL. zVariables and rVariables are counted separately in CDF files.

Keywords

ZVARIABLE

Set this keyword if the Variable is a zVariable and was passed by number. The default is to assume that Variable is an rVariable.

Example

cid = CDF_CREATE('DEMOvardelete',/SINGLE_FILE)

Create 3 zVariables and 1 rVariable:

var1_id = CDF_VARCREATE(cid, 'rVAR1', /CDF_FLOAT)

var2_id = CDF_VARCREATE(cid, 'zVAR1', /CDF_INT4, /REC_NOVARY, $

                        /ZVARIABLE)

var3_id = CDF_VARCREATE(cid, 'zVAR2', /CDF_CHAR, [2,10], $

                        NUMELEM=10, DIM=[5,5])

var4_id = CDF_VARCREATE(cid, 'zVAR3' ,/CDF_REAL8, /ZVARIABLE)

Check the number of variables:

info = CDF_INQUIRE(cid)

HELP, info.nzvars, info.nvars

IDL prints:

<Expression> LONG = 3

<Expression> LONG = 1

Delete the first and third zvariables:

CDF_VARDELETE, cid, 'zVAR1', /ZVARIABLE

CDF_VARDELETE, cid, 1, /ZVARIABLE

info = CDF_INQUIRE(cid)

HELP, info.nzvars, info.nvars

IDL prints:

<Expression> LONG = 1

<Expression> LONG = 1

varinfo = CDF_VARINQ(cid, 0, /ZVARIABLE)
; check on zVAR2

HELP, varinfo, /STRUCTURE

IDL prints:

** Structure <400a3b40>, 8 tags, length=48, refs=1:

IS_ZVAR INT 1

NAME STRING    'zVAR2'

DATATYPE STRING    'CDF_CHAR'

NUMELEM LONG 10

RECVAR STRING    'VARY'

DIMVAR BYTE Array(2)

ALLOCATERECS LONG Array(2)

DIM LONG Array(1)

CDF_DELETE, cid

See Also

CDF_ATTDELETE , CDF_CONTROL , CDF_VARCREATE , CDF_VARINQ