Page 1 of 1
While command
Posted: Mon Dec 24, 2012 12:36 am
by Ellisrh
Is there a while command ? I don't see it
If not is there a substitute or work around?
Re: While command
Posted: Mon Dec 24, 2012 4:27 am
by Mr. Kibernetik
You are right, there is no WHILE command.
How to substitute. For example, this "WHILE" code
A=0
DO WHILE A <= 5
PRINT A
A=A+1
LOOP
can be substituted with
A=0
DO: IF A > 5 THEN END
PRINT A
A=A+1
GOTO DO
END:
Re: While command
Posted: Sun Jan 20, 2013 4:39 am
by Elchoud
I prefer it to be like this:
A=0
DO:
PRINT A
A=A+1
IF A < 6 THEN DO
..... and the program continues
Re: While command
Posted: Wed Mar 20, 2013 12:47 am
by Dalede
There is a difference in the two solutions. The one by Elchoud will always execute the statement at least once since the test is at the end. This is similar to the for/next loop. It tests on the next command so it will always execute once. The earlier solution by Mr. Kibermetic tests at the beginning and will exit before doing anything. So it really depends on what you need.
Dale