Shelling Out To Superbasic

Authors

Publication

Pub Details

Date

Pages

See all articles from QL Hacker's Journal 29

The QL is unique in how QDOS and SuperBasic are sort of rolled into one. Just as we can only have one copy of QDOS running, we can only have one copy of SuperBasic running (OK, I know this is not true for Minerva).

In a traditional operating system model, there is the OS and the Shell. The Shell is a user interface to the operating system. In UNIX there are many different shells; Boune (sh), C (csh), Korn (ksh), etc.. In MS-DOS the shell was in COMMAND.COM. Even with Win95, there is a MS-DOS Shell still available.

In most OS’s, there can usually be more than one shell ruuning at one time. Application programs can fire off another Shell and run one or more commands. The new shell becomes a child process of the calling application.

All of this comes about because the shell is nothing more than another user application. On the QL we are limited in that only one copy of SuperBasic can be run at one time at it must be Job 0.

In QDOS, user applications can call other programs. An editor could call C68 to compile a program that was just edited and saved. But when the command needed to run is a built-in SuperBasic command (which includes loadable extensions), thete is no way to shell out to SuperBasic to run the command.

I ran into this problem when I wanted to run Qliberator from within MicroEmacs. MicroEmacs allows for executing programs from MicroEmacs, but I could not run all the command for QLiberator that I needed. To explain, here are the steps to run QLiberator:

  1. Load the program into SuperBasic
  2. Call “Liberate” to create a working file.
  3. Execute Qlib

Here is a the steps in SuperBasic terms:

LOAD FLP1_TEST_BAS
LIBERATE FLP1_TEST_BAS
EXEC QLIB

Since I can’t call LOAD or LIBERATE from within MicroEmacs, I thought I could write a SuperBasic program and then compile it. This may work with LIBERATE, but LOAD is not a command that QLib will compile.

I thought I was stuck until I started reading the HotKey System II manual. It was there that I ran across the two commands, HOT_CMD and HOT_DO.

HOT_CMD assigns to an ALT key, a command that will be entered in the SuperBasic window (#0). It does not have to be an executable program, but can be a SuperBasic statement or a resident command ( like TKII or DIYtoolkit). HOT_CMD “picks” the SuperBasic interpreter to the top and the command is sent to SuperBasic to be run.

The HotKey System II was designed to be driven by the user. It is the user typing in a HotKey sequence that puts the System into motion. There in a HotKey command that allows automation of the HotKey System: HOT_DO. HOT_DO tells the System to implement a HotKey. HOT_DO(‘a’) is the same as the user hitting the ALT-a keys.

Using HOT_CMD and HOT_DO in conjunction, the programmer can perform actions just as if they were “shelling” out to SuperBasic. In the case stated above, here is how I would use the two commands to automate using Qliberator:

 10 file$ = "flp1_test_bas"
 20 ERT HOT_CMD('a','LOAD file$')
 30 HOT_DO('a')
 40 ERT HOT_CMD('b','LIBERATE file$')
 50 HOT_DO('b')
 60 EXEC QLIB_OBJ  : REMark Just EXEC it.

I can get away with having LIBERATE in a compiled QLIB program, but not LOAD. Here is a way to get around this limitation.

Products

 

Downloadable Media

 

Image Gallery

Scroll to Top