Author Topic: More Loops  (Read 1245 times)

0 Members and 1 Guest are viewing this topic.

Charles Pegge

  • Guest
More Loops
« on: February 23, 2018, 09:12:06 PM »
Extra syntax to improve clarity in loop structures.

loop keywords: do loop while when until repeat redo continue exit break

Most of the permutations are expressed here:

Code: [Select]
  b=0
  while b<=a
    b+=1
  end while ' or endwhile

  b=0
  while b<=a
    b+=1
  wend

  b=0
  while b<=a {b+=1}

  b=0
  do {b+=1} while b<a

  b=0
  do {b+=1} until b>=a

  b=0
  do
    b+=1
  loop while b<a

  b=0
  do
    b+=1
  loop until b>=a

  b=0
  do
    b+=1
    if b<a then continue do
    if b<a then repeat do
    if b>=a then exit do
    if b>=a then break
  loop

  b=0
  do
    b+=1
    continue while b<a   'if/when/while
    continue until b>=a
    repeat until b>=a
    redo until b>=a
    redo until not b<a
    exit when b>=a      'if/when
    exit when not b<a
    break when b>=a     'if/when
  end do


  print "ok"

https://github.com/Charles-Pegge/OxygenBasic/blob/master/OxygenProgress.zip