EXIT

Description:

This command causes the program to exit a looping structure such as DO, FOR, WHILE. It also causes the program to exit subs and functions.

Usage:

  for i = 1 to 100
    print i
    if i > 7 then exit for
  next
  while i < 100
    i = i + 2
    print i
    if i > 10 then exit while
  wend
  do while i < 100
    i = i + 4
    print i
    if i > 13 then exit do
  loop
  print PrintThirdWord$("I love Liberty BASIC")
  print PrintThirdWord$("Hello World")
  call PrintHi 5
  wait

function PrintThirdWord$(w$)
  if word$(w$,3) = "" then
    PrintThirdWord$ = "oops"
    exit function
  end if
  PrintThirdWord$ = upper$(word$(w$,3))
end function

sub PrintHi n
  if n > 10 then exit sub
  for i = 1 to n
    print "Hi"
  next i
end sub