[Skip top navbar]

Andrew Gregory's Web Pages

Marriners Falls, Approx. 38°42'08"S 143°38'32"E


Getting Started


Each library source code module comes with documentation and examples in the comments at the beginning of each file. Be sure to read those comments for further information.

To start developing an application using these modules you will need:

These modules will provide your application with the following general features:

A Minimal Application

Following is the source for a minimal application using one of the Application Manager modules. Note that this example uses my preferred option of preprocessor #include directives.

PROC main: mpStart%:( "init", "" ) ENDP #include "\opl\lib\amsync.opl" #include "\opl\lib\iomngr.opl" PROC init%: EvtFunc$( 1 ) = "hdlkey" :REM handle keypresses EvtFunc$( 17 ) = "hdlsys" :REM handle System commands (optional) ENDP PROC hdlkey%:( key%, kmod%, krep% ) IF amTstUI%:( 3 ) <> 0 REM a dialog or a menu is visible - don't intercept their keys RETURN 0 ENDIF IF key% = 27 RETURN 2 :REM exit application if Escape is pressed ENDIF PRINT REPT$( CHR$( key% ), krep% ); :REM do something with the key ENDP REM Handling System commands is optional, but recommended PROC hdlsys%:( c$, file$ ) IF c$ = "X" RETURN 2 :REM exit application if the System requests it ENDIF ENDP

There are probably as many different opinions of 'minimal' as there are programmers! Strictly speaking it is not necessary to handle System commands, but I think it is a good idea.

The code in the keyboard handler that checks for dialog boxes and menus is not necessary when using the Synchronous Application Manager (as the example is), but if ever you decided to switch to the Asynchronous Application Manager, then that code would be necessary. When used under the Synchronous Application Manager there are never any dialogs or menus visible when the key handler is called.