Multitasking

AMOS Professional can be run at the same time as totally separate programs and utilities such as DPaint III. This allows the creation and testing of original AMOS Professional programs while drawing on the resources of your favourite audio, graphical and utility items.

Provided that your system has at least one megabyte, multitasking is activated by pressing Amiga + A to flick between AMOS Professional and the CLI or Workbench environments.

To make effective multitasking programs, most of the processing time should not be grabbed, leaving only a limited amount of processing power for other tasks, and the following command is provided to solve this problem.

MULTI WAIT

instruction: force a multitask wait vbl
Multi Wait

The MULTI WAIT instruction should be used in the main loop of an AMOS Professional program. It forces a multitask WAIT VBL for situations such as waiting for a menu item to be selected.

This command should not be used to achieve accurate screen synchronisation, as it has been specifically provided for multitasking and may skip several vertical blank periods, depending on the number of tasks being run simultaneously.

The following simple commands are provided to allow complete control over multitasking facilities.

AMOS TO BACK

instruction: hide AMOS Professional and reveal the Workbench
Amos To Back

This instruction allows other programs to be accessed, by bringing forward the Workbench display and hiding AMOS Professional from view.

AMOS TO FRONT

instruction: hide the Workbench and reveal AMOS Professional
Amos To Front

Similarly, this instruction forces AMOS Professional back onto the display, leaving the Workbench environment hidden.

AMOS LOCK

instruction: disable Amiga + A toggle
Amos Lock

The AMOS LOCK command disables the facility to toggle between AMOS Professional and the Workbench by pressing Amiga + A. This can be used to prevent other users from discovering how your program was written!

AMOS UNLOCK

instruction: re-activate toggle between AMOS Professional and Workbench
Amos Unlock

Use this instruction to restore the facility for flipping between AMOS Professional and the Workbench, via the Amiga+A keys.

AMOS HERE

function: report if AMOS Professional is currently at the front of the display
status=Amos Here

AMOS HERE is used to provide a simple report. A value of -1(True) is returned if AMOS Professional is currently displayed, otherwise zero (False) indicates that the Workbench is in view.

Communication between programs

As well as multitasking between AMOS Professional and other programs, communication is allowed between different AMOS Professional programs previously installed in memory.

PRUN

instruction: run a program from memory
Prun "program name"

This command can be used either from Direct Mode or from within a program, and it is a combination of calling a procedure and running another program. It is also extremely powerful! When PRUN is called, it has the following effect:

Here is an example of a boot menu, demonstrating a very simple version of this technique:

Do Screen Open 0,640,200,4,Hires Repeat Input "Please enter a program name to run: ";P$ Exit If P$="",2 Trap Prun P$ If Errtrap : Print "Program not found!" : End If Until Errtrap=0 Wait 50 Loop

If you are not sure about the display before calling another program with PRUN, simply close all current screens. This will also free as much memory as possible. Similarly, if you are not sure about the display after running another program with PRUN, you should also close all of the screens, and then call the main screen initialisation of your original program again.

PRG UNDER

function: report the availability of a program "under" the current program
status=Prg Under

This function is used to report on the accessibility of an AMOS Professional program that is "under" the current program. One of three values can be returned:

Zero indicates that the current program is running normally, under the control of the Editor. Remote editor commands and BGRAB cannot be used.

A value of 1 indicates that the current program is the only program running, but it is not the program currently under the control of the Editor. This happens when an accessory program is run or a "program to menu" option is selected, and remote editor commands are allowed as well as the use of the BGRAB command.

A value of -1 means that the program has been run via another program, using PRUN. In this case, memory banks can be grabbed, but remote editor commands cannot be sent.

EXEC

instruction: send a CLI command to a device
Exec "CLI Command","Output"

The EXEC instruction executes the specified CLI command, via the named output. Output refers to the name of an AmigaDos device, and is held in inverted commas. If these are empty "", NIL: will be used, otherwise the name of the output device must end with a colon.

"CUR:" specifies that the current CLI window is to be used. If this window does not exist, because AMOS Professional was booted from the Workbench, then the EXEC command cannot operate. If "CON:" is used, then a CLI window is opened under the Workbench screen, if possible. Any other Amiga device can be specified, as long as it is interactive, and it will be opened before the CLI command is sent, and closed again after the command has been sent, unless it is the current CLI window.

For example, to execute an external program copied into the C: directory of AMOS Professional, and wait for its completion, this could be used:

Amos To Back : Rem Reveal the Workbench Rem Now launch the program in a small CLI window Exec "Program Name","CON:0/0/160/48/Program Name" Amos To Front : Rem Return to AMOS Pro after the program

PRG STATE

function: return the status of how the current program was originally run
status=Prg State

Finally, here is a useful function which gives a report on how the current program was originally run. PRG STATE can return one of three possible values, as follows:

Value    Meaning
0       Program is run under the AMOS Professional Editor
1       Program is run under run-time only
-1      Program is compiled