Error Messages/40020


Error message examples

The condition for "while" evaluates to an array. It should evaluate to true (non-zero) or false (zero).

Cause

This error is caused when an array is passed as the condition of a while loop. The following code will produce this error as Time is an array and Time > 5 will evaluate to an array.

Local a:= 5;
While (Time > a) Do (
a++;
)
...

Remedies

Correct the condition for the while loop so it evaluates to true or false.

Another possible remedy is to include the Any keyword, i.e.,

Local a:= 5;
While Any (Time > a) Do (
a++;
)
...

But when you do this, the iteration proceeds until all cells pass the condition, which may be inefficient in some cases (such as a convergence algorithm where it converges more precisely in many cells than is really required), and can result is the incorrect results in others (for example, when you want to stop at the first violation, but now some cells proceed further than that).

Suggested revised message

In a construct WHILE <cond> DO <exp>, the condition should be a scalar (true (non-zero) or false (zero)), but not an array. See Ensuring Array Abstraction in Analytica User Guide on how to deal with this.

See Also

Comments


You are not allowed to post comments.