•  Back 
  •  Main 
  •  Index 
  •  Tree View 
  •  Cross references 
  •  Help 
  •  Show info about hypertext 
  •  View a new file 
Topic       : The GFA-Basic Compendium
Author      : GFA Systemtechnik GmbH
Version     : GFABasic.HYP v2.98 (12/31/2023)
Subject     : Documentation/Programming
Nodes       : 899
Index Size  : 28056
HCP-Version : 3
Compiled on : Atari
@charset    : atarist
@lang       : 
@default    : Document not found
@help       : Help
@options    : +g -i -s +z
@width      : 75
@hostname   : STRNGSRV
@hostname   : CAB     
@hostname   : HIGHWIRE
@hostname   : THING   
View Ref-FileDO WHILE condition
DO UNTIL condition
LOOP WHILE condition
LOOP UNTIL condition

condition: bexp

The commands DO and LOOP can be extended using UNTIL and WHILE. The loop
command DO WHILE causes the instructions in the loop to be executed only as
long as condition is true. If the loop begins with DO UNTIL, then it is entered
only if the condition is not true. LOOP WHILE causes the program to jump back
to the DO command as long as condition is true. LOOP UNTIL requires that the
condition must be false for the program to loop back.  Below, the conditions at
DO are testing for true and at LOOP are testing for false.

    DO WHILE condition                        WHILE condition
    '                       corresponds to    '
    LOOP                                      WEND

    DO                                        REPEAT
    '                       corresponds to    '
    LOOP UNTIL condition                      UNTIL condition

The command variants DO, DO WHILE, and DO UNTIL can be combined at will with
LOOP, LOOP WHILE, and LOOP UNTIL, so forming altogether nine types of loops.

Examples:

    DO
    LOOP UNTIL MOUSEK

--> Waits for a mouse button to be pressed.

    DO UNTIL MOUSEK=2
      DO WHILE MOUSEK=1
        LINE 0,0,MOUSEX,MOUSEY
      LOOP
    LOOP UNTIL INKEY$="a"

--> Draws lines when left mouse button is held down. If the right mouse button
    is pressed or the 'a' key is struck the program ends.

    DO UNTIL EOF(#1)
      INPUT #1,a$
    LOOP

--> Reads character strings from channel 1 sequentially, until the file end is
    reached.

    WHILE NOT EOF(#1)
      INPUT #1,a$
    WEND

--> Using WHILE-WEND is slower, since, additionally, NOT is required.