added while in a while with some continue tests
parent
75c8e5dc68
commit
958dfe51fd
|
@ -5,8 +5,10 @@ func while_test ()
|
|||
begin
|
||||
var a, b
|
||||
a := 20
|
||||
|
||||
|
||||
b := test_while()
|
||||
|
||||
print "Loops done in test_while:", b
|
||||
|
||||
print a
|
||||
|
||||
|
@ -29,29 +31,53 @@ end
|
|||
|
||||
func test_while()
|
||||
begin
|
||||
var n, m
|
||||
var n, m, loops_done
|
||||
|
||||
n := 4
|
||||
m := 21
|
||||
m := 10
|
||||
n := 5
|
||||
|
||||
while n > 0 do
|
||||
loops_done := 0
|
||||
|
||||
|
||||
while m > 0 do
|
||||
begin
|
||||
n -= 1
|
||||
if n = 2 then
|
||||
continue
|
||||
|
||||
while m > 0 do
|
||||
|
||||
if m = 7 then
|
||||
begin
|
||||
m -= 1
|
||||
print "Skipping loop 7"
|
||||
continue
|
||||
end
|
||||
|
||||
n := 5
|
||||
while n > 0 do
|
||||
begin
|
||||
|
||||
|
||||
if m = 10 then
|
||||
if n = 3 then
|
||||
begin
|
||||
n -= 1
|
||||
print "-------Skip 3 in inner loop"
|
||||
continue
|
||||
end
|
||||
|
||||
print n, m
|
||||
|
||||
loops_done += 1
|
||||
print "loop:", loops_done, "Values:", m, n
|
||||
n -= 1
|
||||
end
|
||||
|
||||
if m = 5 then
|
||||
begin
|
||||
m -= 1
|
||||
print "<<<<<<Skip after exit of inner while"
|
||||
continue
|
||||
end
|
||||
|
||||
print "######## Loop", m, "done"
|
||||
m -= 1
|
||||
|
||||
end
|
||||
|
||||
return 0
|
||||
return loops_done
|
||||
end
|
Loading…
Reference in New Issue