Developer postOriginal post (opens in a new tab)

Adding Delays

Let's assume you wrote a program in Ozapell Basic to draw a white pixel on a black screen in graphics mode:

BACKCOLOR=COLORBLACK
MODE=1
SETMODE
TEXTCOLOR=COLORWHITE
X=10
Y=10
COLORXY

You run the program and nothing happens. The program executed properly and drew its pixel, but then it returned to text mode when the program ended.

This could also be a problem if a wave audio sound was loaded, played and the program ended. The sound would stop immediately and it might seem as though the sound wasn't playing correctly.

Here are some delays you can add to the end of your program:

REPEAT
UNTIL FALSE

This will create an infinite loop. Only pressing the ESC key will end the program.

REPEAT
INPUT
UNTIL RESULT

This will loop until a key is pressed. INPUT will return a string character in RESULT. If it is an empty string (length of zero), the loop will continue. If a key is pressed (associated with a string character), then the loop will end.

TIME
OLDTIME=RESULT
REPEAT
TIME
RESULT-OLDTIME
RESULT>1000
UNTIL RESULT

This will loop for 1000 milliseconds (one second).