Amos Professional Manual  Contents  Index

Procedures


Make sure that the edit cursor is over the procedure statement, select the [Procedures] option rom the [Editor] menu and trigger the [Open/Close] option, or hit [F9] as a short-cut. The procedure definition is neatly folded away from view, and in normal practice you would be allowed to concentrate on your main program without the distraction of chunks of procedures getting in the way. In other words, you can achieve greater programming clarity in your listings by closing procedures from view. The last example should now look like this:

X> MAIN TITLE
   Procedure MAIN_TITLE

To reveal the procedure at any time, simply move the cursor back to the procedure line and reveal its definitions with [F9] or [Open/Close].

Closed procedures can be executed as normal, and saved or loaded along with an AMOS Professional program listing. But a closed procedure cannot be deleted using the program cursor, and a deletion can only be made if the procedure is opened again or by means of the [Cut] option.

To open and close all of the procedures in the current program, the [Open All] and [Close All] options are provided. Alternatively, you can use the keyboard short-cuts [Amiga]+[Shift] +[0] and [Amiga]+[Shift]+[C], as already explained under the full list of Editor options in Chapter 4.1.

Jumping in and out of a procedure
You should be familiar with the use of ON for jumping to a GOSUB routine. It is just as simple to use this structure with procedures.

ON ... PROC
structure: trigger a jump to a procedure
On variable value Proc NAME

In this case, if a variable holds a particular value, a system is automatically triggered that forces a jump to a named procedure. Of course you can have as many values triggering off as many jumps to different procedures as you want. For example:

X> On X Proc PROCEDURE1,PROCEDURE2

Which is exactly the same as saying:

X> If X=1 Then PROCEDURE1
X> If X=2 Then PROCEDURE2

Normally, procedures will only return to the main program when the END PROC instruction is reached. But supposing you need to jump out of a procedure instantly.

POP PROC
structure: leave a procedure immediately
Pop Proc

Back    Next
05.05.03