--> procedure test(integer start, stop, step, string legend, bool bFor) sequence res = {} if bFor then try for i=start to stop by step do res &= i if length(res)>9 then exit end if end for res = sprint(res) catch e res = e[E_USER] end try else integer i = start while (step>=0 and i<=stop) or (step<=0 and i>=stop) do res &= i if length(res)>9 then exit end if -- if i=stop then exit end if -- if step=0 then exit end if i += step end while res = sprint(res) end if printf(1,"%-43s: %s\n",{legend,res}) end procedure for i=1 to 2 do ?iff(i=1?"for":"while") test(-2, 2, 1, "Normal" ,i=1) test(-2, 2, 0, "Zero increment" ,i=1) test(-2, 2,-1, "Increments away from stop value" ,i=1) test(-2, 2,10, "First increment is beyond stop value" ,i=1) test( 2,-2, 1, "Start more than stop: positive increment" ,i=1) test( 2, 2, 1, "Start equal stop: positive increment" ,i=1) test( 2, 2,-1, "Start equal stop: negative increment" ,i=1) test( 2, 2, 0, "Start equal stop: zero increment" ,i=1) test( 0, 0, 0, "Start equal stop equal zero: zero increment",i=1) puts(1,"\n") end for