N_ELEMENTS
Syntax | Return Value | Arguments | Keywords | Examples | Version History | See Also
The N_ELEMENTS function returns the number of elements contained in an expression or variable.
Syntax
Result = N_ELEMENTS(Expression)
Return Value
Returns the number of elements.
Arguments
Expression
The expression for which the number of elements is to be returned. Scalar expressions always have one element. The number of elements in an array is equal to the product of its dimensions. If Expression is an undefined variable, N_ELEMENTS returns zero.
Keywords
None.
Examples
Example 1
This example finds the number of elements in an array:
Example 2
A typical use of N_ELEMENTS is to check if an optional input is defined, and if not, set it to a default value:
The original value of roo may be altered by a called routine, passing a different value back to the caller. Unless you intend for the routine to behave in this manner, you should prevent it by differentiating N_ELEMENTS' parameter from your routine's variable:
Version History