Variable Count Syntax

In (syntax) version 8 and later, the number of values of a variable can be obtained with a pound sign ("#") after the dollar sign, e.g. $#var. This returns a long count of the number of values of the variable in the current context (i.e. 0 or 1 if looping over the variable, total number of values otherwise). It is a shorthand to save a call to <count>.

Note that this syntax does not produce an "lvalue", i.e. it cannot be used on the left-side of an assignment, or anywhere else that a variable is expected to be assignable or looped over (e.g. <sort>, <export>, <fetch urls>, <nslookup hosts> etc.).


Copyright © Thunderstone Software     Last updated: Jul 17 2021
Copyright © 2021 Thunderstone Software LLC. All rights reserved.