The N_TAGS function returns the number of structure tags contained in a structure expression.
Result = N_TAGS( Expression [, /DATA_LENGTH] [, /LENGTH] )
Returns the number of structure tags and optionally returns the size, in bytes, of the structure.
The expression for which the number of structure tags is to be returned. Expressions that are not of structure type are considered to have no tags. N_TAGS does not search for tags recursively, so if Expression is a structure containing nested structures, only the number of tags in the outermost structure are counted.
Set this keyword to return the total length of all the data fields contained within the structure, in bytes. This differs from LENGTH in that it does not include any alignment padding required by the structure.
The length of the data for a given structure will be the same on any system, as long as the data does not contain strings.
If a data field contains a string, the DATA_LENGTH keyword returns the length of the string's internal descriptor, rather than the length of the string data. (In IDL, strings are represented internally using a descriptor structure that contains information about the string, including its length and a pointer to the string data.) This means that on a given machine, the DATA_LENGTH keyword will report the same length value for all fields containing string data, regardless of the contents of the strings.
| Note |
Set this keyword to return the length of the structure, in bytes.
| Note |
Find the number of tags in the system variable !P and print the result by entering:
PRINT, N_TAGS(!P)
Find the length of
PRINT, N_TAGS(!P, /LENGTH)
Introduced: Original
CREATE_STRUCT, N_ELEMENTS, TAG_NAMES, Structures