Amos Professional Manual  Contents  Index

Control Structures


There is a traditional group of instructions that allow computer programs to make decisions. They are usually known as control structures. This Chapter explains how AMOS Professional takes (lie best of these traditions and uses them to give your Amiga a logical brain.

GOTO
structure: jump to a specified place in the program
Goto label
Goto line number
Goto expression

A computer program that can only obey a list of instructions one after the other is a very limited computer program indeed. One way of forcing programs to jump to specified locations is to use the old fashioned GOTO structure, followed by a target destination. In AMOS Professional, these destinations can be a label, a line number or a variable. These are explained in Chapter 5.1.

label markers can consist of names that use any string of letters or numbers, as -well as the underscore character "_", and they must be ended with the colon character ":" as follows:

E> Print "Jump in two seconds" : Wait 100
   Goto LABEL_MARKER
   Wait 180000 : Rem Wait one hour
   LABEL_MARKER:
   Print "Now is the time to jump!"

Numbers may be used to identify specific lines, and the program can be commanded to GOTO one of these optional markers, like this:

E> Goto 5
   Print "I am being ignored"
   5 Print "I am line 5"

It should be obvious that these identification numbers have nothing to do with the number of lines in a program, but they may still lead to confusion. Labels are much easier to remember and to locate.

Expressions can also be used for this purpose, and the expression may be any string or integer. Strings hold the name of a label, and integers return a line identification number. Here is an example:

E> BEGIN:
   Goto "BED"+"2"
   End
   BED1:
   Print "This Bed will never be used"
   Bed2:
   Print "Welcome to Bed Two!"
   Wait 20
   Goto BEGIN
Back    Next
05.04.01