gaslouk
Full Member
Hi from beautiful Greece.
Posts: 130
|
Post by gaslouk on Feb 25, 2023 2:38:28 GMT -5
|
|
|
Post by tsh73 on Feb 25, 2023 4:47:11 GMT -5
While condition 'with possible [exit while] wend is exactly the same as do While condition 'with possible [exit do] loop Just an older form. So Command of the day:Do....Loopcovers it all.
|
|
|
Post by Walt Decker on Feb 25, 2023 12:27:47 GMT -5
' A = 1 WHILE A < 20 A = A + 1 WEND PRINT "WHILE "; A
A = 50 WHILE A > 20 A = A - 1 WEND
PRINT "WHILE "; A
A = 1
DO UNTIL A > 20 A = A + 1 LOOP PRINT "DO UNTIL "; A
DO A = A - 1 LOOP UNTIL A < 10 PRINT "LOOP UNTIL "; A
A = 50 DO WHILE A > 20 A = A - 1 LOOP PRINT "DO WHILE "; A
DO A = A + 1 LOOP WHILE A < 50
PRINT "LOOP WHILE "; A
END '
WHILE and DO can directly use the result from a function, e. g.
WHILE FN.DoSomething(SomeValue) = 0 WHILE FN.DoSomething(DomeValue) > SomeNumber WHILE FN.FetchString$(A.String$) <> ""
DO UNTIL FN.DoSomething(SomeValue) = 0 DO UNTIL FN.FetchString$(A.String$) <> "" DO WHILE FN.DoSomething(SomeValue) = 0
DO LOOP WHILE FN.DoSomething(SomeValue) = 0
DO LOOP UNTIL FN.FetchString$(A.String$) <> ""
WHILE, DO, and FOR/NEXT can be nested, e. g.
'WHILE 1 DO UNTIL WHILE 2 FOR I = 0 TO SomeNumber NEXT I WEND LOOP ' WEND
DO NOT USE GOTO to exit any loop. Use EXIT FOR, EXIT WHILE, EXIT DO instead. If the loop is in a SUB/FUNCTION you can use EXIT SUB or EXIT FUNCTION within a loop structure.
|
|