Reference Guide > M–N Routines > N_ELEMENTS Function
  

N_ELEMENTS Function
Returns the number of elements contained in any expression or variable.
Usage
result = N_ELEMENTS(expr)
Input Parameters
expr—The expression for which the number of elements will be returned.
Returned Value
result—The number of elements contained in any expression or variable.
Scalar expressions always have one element. The number of elements in an array is equal to the product of its dimensions. If expr is an undefined variable, N_ELEMENTS will return zero.
Keywords
None.
Example
In this example, N_ELEMENTS is used to determine the number of elements in a two-dimensional array.
; Create a 3-by-2 integer array.
a = INDGEN(3, 2)
PRINT, a
; PV-WAVE prints:
; 0       1       2
; 3       4       5
; Display the number of elements in a.
PRINT, N_ELEMENTS(a)
; PV-WAVE prints: 6
; Delete the variable a.
DELVAR, a
INFO, a
; PV-WAVE prints: VARIABLE    UNDEFINED = <Undefined>
PRINT, N_ELEMENTS(a)
; PV-WAVE prints: 0
See Also
N_PARAMS, N_TAGS, PARAM_PRESENT, SIZE, TAG_NAMES

Version 2017.1
Copyright © 2019, Rogue Wave Software, Inc. All Rights Reserved.