Error, invalid subscript selector
Description
Examples
This error occurs when you use the selection operation incorrectly when selecting from a list or sequence. For more details, see Selection Operation. Errors due to invalid subscripts are generated by (but not limited to) the following examples.
Example 1
L≔a,b,c,d,e
L:=a,b,c,d,e
L7
Five elements are assigned to list L. This error occurred because the index (subscript in 2-D Math) of the selection operation is out of range for the number of elements in the given list.
Solution:
To fix this error, the index should be within the range of the number of list elements.
L2
b
Note: Indices are notated using either subscript or square brackets. Both methods will return the same results.
Example 2
S≔w,x,y,z
S:=w,x,y,z
S−6
In this example, four elements are assigned to sequence S. Negative values can be used for the index, and are used to count the elements starting from the end of the sequence, with -1 being the last item, -2 the second-last item, and so on. This error occurred because the negative index is out of the range of the given number of sequence elements.
To fix the error, ensure the index (whether positive or negative) is within the range of the number of sequence elements.
S−2
y
Example 3
L3..8
Ranges (a..b) can be used for selecting elements, but they must be within range of the number of list elements. This error occurred because the range endpoint (8) of the index is out of range of the number of list elements.
L3..5
c,d,e
Example 4
L4..2
If the index is a range of positive integers, the lower bound must be less than or equal to one more than the upper bound. Specifically, A3..3 selects a single element, A3..2 produces an empty selection, and A3..1 is not permitted. Negative integers in a range are first converted to equivalent positive integers, then this requirement is imposed.
L5..5
e
L4..3
L−1..−2
Example 5
S1.2
The index of the selection operation must evaluate to an integer, a range, or NULL. This error occurred because the index is a non-integer. This could also be a syntax error; ranges must include two periods.
S1
w
S1..2
w,x
S
w,x,y,z
See Also
list
range
selection
sequence
Download Help Document