HOW TO USE: Advanced / Developing with SWITCH! 2.0

Ed tells program developers how to make their HP 95LX applications System-Manager compliant under SWITCH! (SWITCHable).

By Ed Keefe

[Ed Keefe is an author, programmer, computer science instructor, and long-time contributor to support publications for HP computers. He is the president of the FastAid Company, 314 S.W. Logan, Ankeny, IA 50021. Ed's CompuServe ID# is [75300,3667].]

Ever since the HP 95LX came on the market users have been fascinated with System Manager's ability to switch back and forth between its built-in applications. However, writing System Manager Compliant applications (ones that have the same look and feel as the built-in applications) is not an easy task.

The first step towards making this easier was a "loader" program developed in UTIL Forth (see review, page 31, Jan/Feb 92 issue). This program gives almost any MS-DOS application the ability to pop-up over all the built in applications, except for 1-2-3. Unfortunately, none of the built-in programs can pop-up over DOS applications loaded in this fashion.

Next came Swift!Basic (see review, page 32, Jul/Aug 92 issue), which gave us with the ability to create true System-Manager compliant programs in BASIC. Mark Scardina used Swift!Basic to create SWITCH!.EXM, a menuing system that can run up to 48 different DOS and System-Manager compliant programs at the push of a couple of keys. Mark's latest version of SWITCH! (2.0) makes creating System-Manager compliant programs easier for the rest of us.

A New SWITCH!

The new SWITCH! 2.0 Developer's Kit lets you turn any Pascal, C, C++, Modula II/III, etc. program into a "task-SWITCHable" application. Not only will your program be able to pop up over any of the built-in applications (including 1-2-3), any of the built-in applications will be able to pop up over your application.

The amount of recoding you'll have to do with your program is minimal. Adding a few calls to DOS Interrupt 63hex is all it takes. All the function calls are implemented in the *.SWI loader files created by SWITCH! Loader Generator (found in the Developer's Kit). Note that the loader is a .SWI file instead of the usual ".EXM". Apparently System Manager is not as picky about executable file names as is DOS.

Technical Specifics: For Programmers Only!

DOS programs implementing these calls to Interrupt 63h will communicate with System Manager and allow task switching and alarm handling on the HP 95LX. Since Interrupt 63h is always present on the HP 95LX, these calls can be structured to allow for continued DOS compatibility of the calling program.

Programs calling these functions should follow these guidelines for maximum usability:

  1. 1. Programs should check if they are on an HP by using Function 4DD4h Int 15h which returns 4850h in BX.
  2. 2. Whenever possible, programs should allocate any required memory before allowing task switching as the memory may not be available upon return. The Loader provides for minimum memory allocation.
  3. 3. Programs should release all unused memory prior to allowing task switching to allow additional applications to be launched.
  4. 4. Programs should be set up to respond to an "extended keyboard". Even though all of the extended keys are not present on the HP 95LX, it does, nonetheless use extended keycodes to access the blue function keys. If your program does not use the blue keys, nor any of CHAR function keys, you may omit this prescription.
  5. 5. Programs should never access COM2 nor use COM1 for interrupt driven transmission without a modified low level routine.
  6. 6. Mode 7 text is the only video mode available. Graphics are implemented in a non-standard way.(How well we know!)
  7. 7. Whenever possible, programs should be implemented as an EXE-type executable file. When a COM format is required, the stack area needs to be explicitly allocated and sized on startup due to a bug in MS-DOS 3.22 that allows the stack to over-write the C: drive if programs are launched with less than 64K of memory.
  8. 8. Programs should not get keyboard input below Int 16h. i.e. do not use Int 09h.

  9.  

     

Interrupt 63h Functions

The following Interrupt 63h functions are provided in the *.SWI loaders available to launch DOS programs. These functions are set up by SWITCH!.COM, which is a System Manager Shell program available from ACE Technologies. All registers not required for output will be returned unchanged.

Int 63h, Function ACE0h : SWITCH Unlock

This function should be called when an application can be interrupted at the next keyboard input. The default condition is locked and task switching is only allowed if an UNLOCK is received. Function ACE0h may also be used to detect the presence of SWITCH!.COM and System Manager by checking that AX is returned unchanged. If SWITCH! is not present AX will be different.

Child processes will not be SWITCHable unless they explicitly called the UNLOCK function.

Int 63h, Function ACE1h : SWITCH Lock

This function prevents the program from being task switched by System Manager. An UNLOCK should always follow as soon as the program is again interruptible. It is not necessary to call this function if an UNLOCK has not been called. Programs are defaulted to the LOCK condition.

Int 63h, Function ACE2h : Lock COM1

This function prevents System Manager from opening the COM port and thereby maintaining control. An unlock should always follow as soon as the COM port is again available. This will not prevent programs that go directly to the port from disrupting the link.

Int 63h, Function ACE3h : Unlock COM1

This function reverses the lock function to allow for access to COM1.This function should be called as soon as the program makes COM1 available.

Int 63h, Function ACE4h : Stuff Scancode

This function stuffs the keyboard buffer with the passed keystroke upon returning to System Manager. This will allow for the return to a specific application.

Loading Programs

SWITCHable applications are launched from System Manager by a *.SWI Loader. This loader communicates with SWITCH!, and accomplishes the following before launching the application.

First the loader shrinks 1-2-3 if open and allocates required memory (a minimum of 64K for *.COM files).

The loader may, then, display an error message if the necessary memory is not available. If all goes well, the loader swings into operation. It moves System Manager application data segments and itself to the top of memory. Then it chains to INT 16h to provide a link to System Manager. Next, it chains to INT 21h to protect against re-entering DOS. The loader sets the required, display characteristics, the required startup drive and directory, and, finally, executes the application.

Once an application is running, it is not able to be task switched until the UNLOCK call is made. Upon receiving a valid hotkey the following events occur: First, any unused memory is temporarily reallocated to the loader. INT 23h and 24h are saved for restoring upon return. The screen and its mode are saved. The cursor position and size are saved and control is given to System Manager.

Upon return, the process is reversed, but now the memory is returned to the application and any free System Manager memory is allocated to the loader.

The System Manager alarm function is supported. To make the alarm independent of a keypress, a keyboard loop using INT 16h Func 1h or 11h is required. Upon activation, the screen will be saved and cleared, the message displayed, and the screen redrawn.

Conclusions

Only one SWITCHable application can be in memory at any one time. Prior ones will be swapped to disk with the reserved space specified when launching SWITCH!.COM.

SWITCH! is good news for Pascal and Modula II programmers. It is possibly the only way that any of our programs will ever achieve a good measure of System Compliancy.

Until next time.

Relocations