3-Lib banner

The Absolute Beginners Guide to OPL

P101 - OPL/16 - Setting up


These tutorials use the 16-bit version of RMR Software's excellent "RMREvent" example program, disecting it bit by bit to show you how and why it works. Make sure you've got the latest version, v1.00.

Last time, I explored the APP...ENDA section at the top of RMREvent, showing its role in presenting the program to the Series 3 system screen. Let's now look further into the program itself. A block of seven lines of GLOBAL statements at the start sets up the variables that are needed throughout. Note that although it's possible to declare GLOBAL variables at the top of any procedure in a program, things are significantly easier to understand (and thus to sort out problems at a later stage) if the declarations are done right at the start of the main procedure. There's not a lot to say about the variable names used here, as they're all sensibly named within OPL/16's constraint of allowing only 8 characters for each.

Screen shot

Moving on, the lines:

File$=CMD$(2)
Cmnd$=CMD$(3)

will probably look unfamiliar to you. The first duty of a professional SIBO program after it has been launched is to find out from the operating system which document file (if any) has been requested by the user and what he or she wants done with it. The special 'command letter' that gets passed through here to an OPL/16 program will either be "C" (for "Create") or "O" (for "Open"), depending on how the user activated RMREvent. For example, the user might have done Psion-N underneath the program's icon, in which case "C" would get passed through. And of course File$ will contain the full path and file name of the requested RMREvent document.

Screen shot

Program$ is obvious, but Path$ needs a word of explanation. By the time you finish your masterpiece, you'll have a collection of graphics, sound, resource and help files, all of which are needed at some point by the main program. The Psion convention is to stick all of them in an \APP\RMREVENT\ directory (replace with your own program name, of course), where they'll be neatly out of the way. Rather than explicitly write out this directory name dozens of times throughout the program, it's a good idea to use a variable like Path$ instead.

Similarly for Version$ and Date$, which are far better set to variables than changed ad-hoc within the code.

The rest of the main procedure looks disturbingly brief. The key, as you'll guess, is the DO...UNTIL loop, which sits there processing keystrokes and events until the program is one day closed down. We'll look at this loop in the next tutorial. In the meantime, note the Init: procedure. There are usually so many things to do at the start of an application (setting up variables, loading in graphics, reading configuration files etc) that it's tidier to keep them all in one place. Search ahead and let's see what RMREvent does in its Init: procedure:

Screen shot

Screen shot

See you next week, when we'll be looking at Run: and the vitally important concept of the 'event loop'.


Go to next lesson | Programming index