Lesson 2 - Lbl, Goto, Return, Pause
These are simple commands that you will definitely use, Return probably the least. First, there is the Label (Lbl) command which allows you to return to that label.
:Lbl
A
;Identifies Label A
:B+1->B
;Adds 1 to "B" and stores the result in "B"
:Goto
A ;Goes back to A
to repeat
Labels like these are
versatile and can be used in many statements. They are
important because they allow you to return to an area to repeat
something or to go to a place If a command is true. You
will learn how to use "If" statements later. That
covers If and Goto. These statements are used constantly
and form the basis of most programs.
Next there is the Return
statement. I use this in BASIC shells to Return to a
calling program.
Calling Program
:Lbl Save ;Goes
to label "Save" probably from a Menu
:Save
;Runs the program Save
:Goto Top ;Goes to Label Top,
probably the start of the menu that went to the Label in the 1st
place
Program Save
:Return ;Returns to the calling program
Using this in a
shell, when the user runs a program and exits the program, it
returns to the shell. This provides a seamless operating
system from shell to program and back again without the user
returning to the homescreen. Return can be used for other
things, but this is the only worthwhile use I have found.
Finally, there is
Pause. This is usually used when displaying text (Lesson
4). After displaying the text, the programmer uses Pause to
wait for enter to be pressed and go on in the program.
:ClLCD
;Clears the home screen
:Disp
"Hello!"
;Displays Hello!
:Pause
;Pauses, and waits for enter to be pressed
:ClLCD
;Clears the home screen
:Disp "This is a cool
program" ;Displays This is a
cool program
As you can see, Pause
is a basic command that is very helpful in choose your own
adventures, instructions, just about anything.