Download eV+ Language Reference Guide, v2.0.x

Transcript
LAST real-valued function
LAST real-valued function
Syntax
LAST (array_name[])
Function
Return the highest index used for an array (dimension).
Usage Considerations
If an automatic variable is referenced (see the AUTO instruction), this function returns the
index specified in the AUTO statement that declared this array, regardless of which elements
have been assigned values.
Parameter
array_name[]
Name of the array to be tested. Any type of eV+ array variable
can be specified: real-value, location, string, or belt. At least
one array index must be omitted (see below).
Details
This function can be used to determine which elements of an array have already been
defined. For one-dimension arrays (for example, part[ ]), this function returns the largest
array index for which an element is defined. (See the first example below.)
For multiple-dimension arrays (for example, $names[,]), this function returns the largest
array index for which an element is defined for the (left-most) dimension that is omitted
from the array specification. (See the second example below.) There cannot be an index
specified to the right of an omitted index.
Note that the value returned by this function is an index, not an array element.
Furthermore, the value is not a count of the array elements that are defined-it is the largest
index for which an array element is defined.
The value -1 is returned if the array does not have any elements defined for the requested
dimension. That is, -1 is returned if any of the following situations occur:
l
The array does not exist.
l
The array has more or fewer dimensions than the number indicated in the function
call. (For example, LAST(a[ ]) will return -1 if the array a has two dimensions.)
l
The specified dimension in a multiple-dimension array has not been defined at all. (For
example, LAST(a[20,]) returns -1 if LAST(a[,]) returns 19. That is, no elements a
[20,i] exist.)
eV+Language Reference Guide, v2.0.x Updated: 5/8/2013
Page 313