Amos Professional Manual  Contents  Index

Control Structures


For that to work properly, X must have a value from 1 up to the number of the highest possible destination. Any other values would cause problems. In fact the third line of that example is a very economical way of writing the following lines:

X> If X=1 Then Goto LABEL1
   If X=2 Then Goto LABEL2
   If X=3 Then Goto LABEL3

Now change the third line of the last example to this:

E> On X Goto LABEL3,LABEL2,LABEL1

Gosub. The use of an ON GOSUB structure is identical to ON ... GOTO, except that it must employ a RETURN to jump back to the instruction immediately after the ON ... GOSUB statement. Destinations may be given as the name of a label, or the identification number of a line between 1 and the maximum number of possible destinations.

ON is also used with the ON BREAK PROC structure, as well as ON ERROR GOTO, which are explained in the relevant sections of the Procedures and Error Handling Chapters of this User Guide.

EVERY
instruction: call subroutine or procedure at regular intervals
Every time Gosub label
Every time Proc name

The EVERY statement is used to call up a sub-routine or a procedure at regular intervals, without interfering with the main program. Simply specify the length of time between every call, measured in 50ths of a second. Obviously the time taken for a sub-routine or a procedure to be completed must be less than the interval time, or an error will be generated.

After a sub-routine has been entered, the EVERY system is automatically disabled. This means that in order to call this feature continuously, an EVERY ON command must be inserted into a sub-routine before the final RETURN statement. Similarly, EVERY ON must be included in a procedure before returning to the main program with an END PROC. For example:

E> Every 50 Proc TEST
   Do
    Print At(0,0); "Main Loop"
   Loop
   Procedure TEST
    Shared A
    Inc A: Print "This is call number ";A
    Every On
   End Proc
Back    Next
05.04.11