Here is an example of a boot menu, demonstrating a very simple version of this technique:
E> 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.