ANY-maze Help > The ANY-maze reference > The Protocol page > The elements of a protocol > Testing > Procedures > Running procedures > Errors and warnings while running a procedure > Warning: The index to the array variable was not a valid value

Warning: The index to the array variable was not a valid value

Description

When a user-defined variable is set up as an array consisting of a number of values, these individual values can be accessed using the 'index' of the value in the array. For example, an array called 'Count' which is set up to have 4 values can provide access to the individual values in the array using Count(1), Count(2), Count(3), and Count(4).

When using an expression in a procedure to access a variable's index in this way, you can enter specific numeric values, or alternatively, the procedure can use the results of other numeric expressions for the indexes.

If a specific numeric value is used for the index, then the procedure editor can detect whether this value is valid when the procedure is checked for errors - if invalid, then an Error will be displayed in the list of errors and warnings at the bottom of the procedure editor and the procedure will not be valid.

However, if the result of an expression is used as the index, it's not possible for the procedure editor to work out what value that expression will have when it is actually run, so ANY-maze can only check the value when it is actually used in the procedure. In this case, if the expression results in an invalid index for the variable, a warning will be displayed in the Test details report and the value retrieved from the variable will be set to #N/A (if the type of expression returned should be numeric), False (if it's a True/False value), or empty text (if it's a text expression).

Example

The following loop initialises all the values of a four-value array variable using a counter. However, if you look closely at the way the loop works, it will actually run through the loop 5 times - so the last time through, it will be trying to access Tone Frequency (5), which is an invalid index for an array with 4 values.

  

  

Figure 1. This procedure uses a loop to initialise an array of four tone frequencies. However, this will generate an error because the last time through the loop, the value of the 'Index' variable will be 5, and there are only 4 values in the array.

See also:

 Errors and warnings while writing a procedure 
 Errors and warnings while running a procedure 
 User-defined variables 

© Copyright 2003-2026 Stoelting Co. All rights reserved

ANY-maze help topic T0549