Do you have any information about how to make an Amiga program boot itself if the Workbench is not already loaded? This would be useful to a programmer who doesn't want someone else to break into the program while it is loading.
The answer is to be found in a file named startup-sequence, which is found in the s (sequence) subdirectory of the Workbench disk. If a file of this name is present, AmigaDOS automatically executes all the commands it contains before turning control over to the user. From the AmigaDOS CLI, you can use the TYPE command to examine this file, or ED to modify it. A normal startup-sequence file ends with these two commands:
loadwb endcli > nil:
The first command tells AmigaDOS to load the Workbench, and the second terminates the startup sequence, closing the current CLI window and throwing away its output (directing its output to NIL:, the null device).
If the program you wish to run is one that can run from the Workbench or CLI, you can run it from startup-sequence simply by inserting its name before the endcli command. The program will run from startup-sequence just as if you had typed its name at the CLI prompt. For instance, if you want to run a program named myprog,you could edit the last lines of startup-sequence to look like this:
loadwb myprog endcli > nil:
AmigaDOS will still load the Workbench, but before turning control over to the user, it runs the program named myprog. If myprog terminates normally, the startup-sequence continues with the last line, which terminates the CLI and places you on the Workbench as usual. If you delete the endcli command from startup-sequence, you will find yourself at the CLI prompt when myprog terminates.
Of course, it's up to you, as the creator of myprog, to determine when, if ever, you want the user to escape the program. If the program is designed to terminate normally (for instance, when you are using it), but you want others to be barred from examining it, you could delete the loadwb command from the example startup-sequence file. When you reboot with this file, AmigaDOS does not load the Workbench. When you terminate myprog, AmigaDOS executes the endcli command as before. But when you return to the Workbench, the screen is devoid of any disk icons and contains no menus. Without menus or icons of any sort, the user is precluded from doing anything except turning off the power or rebooting with another disk.
You also can run BASIC programs automatically when the computer boots up. To run the BASIC program named basic-prog, for instance, you could edit the last lines of startup-sequence as shown here:
loadwb amigabasic basicprog endcli < nil:
When AmigaDOS executes this file, it loads and starts BASIC, which in turn automatically loads and runs the program basicprog. If you execute a SYSTEM command from BASIC, startup-sequence executes the endcli command and returns you to the Workbench as usual.
It's fairly simple to prevent someone from examining a BASIC program which runs automatically from startup-sequence. All you need to do is disable the normal BASIC menus and use ON BREAK to prevent with CTRL-C. The following program demonstrates the basic techniques.
‘ Turn off BASIC menus FOR j = 1 TO 4 MENU j, 0, 0,"" NEXT J ‘ Enable break trap ON BREAK GOSUB Gotcha BREAK ON ‘ Loop: x$ = INKEY$ IF UCASE$(x$) = "Q" THEN BREAK OFF MENU RESET STOP ENDIF GOTO Loop ‘ Gotcha: PRINT "You can't break out that way…" PRINT "Press Q to quit." RETURN
The MENU commands cause all of the normal BASIC menus to disappear, preventing anyone from breaking out by selecting the STOP menu option. The ON BREAK GOSUB command tells BASIC to go to the designated subroutine whenever it detects the CTRL-C key combination, and the BREAK ON command activates the trap. At this point, it's impossible to break out by using the menus or the keyboard.
This program provides a "back door" command (the Q key) that allows the user to exit under controlled circumstances. In this case, we simply disable the break trap, turn the menus back on, and halt the program with STOP. There are a number of practical reasons, apart from secrecy, why you might want to prevent someone from breaking out of a program. A database program, for instance, might need to insure that all disk files are updated and closed properly before it relinquishes control. Custom screens and/or windows should also be closed when no longer needed, to avoid wasting the memory they consume.
If you don't provide a back door, of course, the user has no way to escape the program short of rebooting the computer. That method would be suitable for a case where you wish to allow someone to use the program, but not to examine it in any way. You could also allow an escape from BASIC, but return the user to a "dead" Workbench as described above. If you substitute SYSTEM for STOP in the BASIC example, you will exit BASIC and return to the startup-sequence file. If that file was edited to eliminate the LOADWB command, you will go back to a useless Workbench screen.