While..Do
While (test) Do body
While evaluates body repeatedly as long as test<>0.
In order for While to terminate, body must produce a side-effect on a local variable that is used by test, causing test eventually to equal 0. If test never becomes false, While continues to loop indefinitely. If you suspect that might be happening, type Control+Break or Control+. (Control+period) to interrupt evaluation.
While returns the final value found in the last iteration of body, or Null if no iterations occur.
Test must evaluate to an atomic (non-array) value; therefore, it is a good idea to force any local variable used in test to be atomic valued. While is one of the few constructs in Analytica that does not generalize completely to handle arrays. But, there are ways to ensure that variables and functions using While support Intelligent Arrays and probabilistic evaluation.
Examples
var n := 1; while n<1000 do n := 2*n --> returns 1024
var x := 1; var prev := 0; while abs(x-prev)>1e-6 do ( prev:=x ; x:=1 + 1/(1+x) ) --> returns 1.414214
Enable comment auto-refresher