N_TAGS Function
Returns the number of structure tags contained in any expression.
Usage
result = N_TAGS(expr)
Input Parameters
expr—The expression for which the number of structure tags will be returned.
Returned Value
result—The number of structure tags contained in any expression.
Keywords
None.
Discussion
Expressions which are not of structure type are considered to have zero tags. N_TAGS does not search for tags recursively, so if expr is a structure containing nested structures, only the number of tags in the outermost structure are counted.
Example
In this example, a structure with three fields is created. Function N_TAGS is applied to the structure and to each field of the structure. The first two fields of the structure are not of type structure. The third field of the structure is of type structure, with two fields.
** Structure EXAMPLE, 3 tags, 32 length:
 
T1 INT
Array(3)
T2 FLOAT
7.00000
T3 STRUCT
-> FIELD3 Array(1)
 
; Create the structure.
b = {example, t1: [1, 2, 3], t2: 7.0, $
   t3: {field3, t3_t1: 99L, t3_t2: [2, 4, 6]}}
INFO, b, /Structure
; PV-WAVE prints:
; ** Structure EXAMPLE, 3 tags, 24 length:
;   T1 INT       Array(3)
;   T2 FLOAT            7.00000
;   T3 STRUCT    -> FIELD3 Array(1)
; Display the number of tags in b.
PRINT, N_TAGS(b)
; PV-WAVE prints: 3
; Display the number of tags in each field of b.
PRINT, N_TAGS(b.t1)
; PV-WAVE prints: 0
PRINT, N_TAGS(b.t2)
; PV-WAVE prints: 0
PRINT, N_TAGS(b.t3) 
; PV-WAVE prints: 2
See Also