Over the last 6 months, since session 19, I've added 15 parts to my programming tutorial series, all geared towards OPL/32 and the Series 5. It's time now to redress the balance, returning to SIBO, OPL/16 and the Series 3. [FX: cries of 'Hoorah'...] If you've gotten to this stage, you'll hopefully have completed the first 19 sessions and are confident in making up simple programs. It's now time to take the next step.
Rather than persist with the clumsy MiLo example (clumsy because of all the compromises made for OPL/32 compatibility in the lessons), I'm going to mimic what I did in the OPL/32 sessions by taking the new 16-bit version of RMR Software's excellent "RMREvent" example program and disecting it bit by bit to show you how and why it works. Make sure you've got the latest version.
The main difference between our simple MiLo code and RMREvent is the word "event". Professional Psion applications are built around an 'event-driven' framework, in which standard key presses, system events (powering on, closedown commands), menu shortcut keys, expiring timers etc. are all handled with a minimum of impact on the Series 3's operation. Starting off with a well-programmed and efficient event loop will save you many, many hours of frustration later on when you get to the debugging stages of writing your masterpiece.
Load up the RMREvent code in the OPL editor:
The first thing you'll notice is the section of code starting APP and ending ENDA, which you won't have seen before. Up 'til now, the OPL program concerned had always been run by translating it into an .OPO file and then hitting "Y" when asked if we wanted to run it automatically. You won't be surprised to discover that 'professional' OPL programs use a more sophisticated system.
By including a graphic icon inside the translated code, RMREvent manages to make itself compatible with the Series 3 system screen. Before going any further, translate the program. When finished, OPL will tell you and then stop with a confirmation dialog. It's usual at this point to stop and scratch your head, wondering what to do next, but don't worry - simply press 'System' and use Psion-I to 'Install' the newly created 'Rmrevent.opa' program file. All being well, it'll pop up on your system screen, showing off its icon (a miniature Psion):
Go ahead and run the new program (you know you want to!)...
There's a lot to look at here, but for now just exit the example program in the usual way (Psion-X)
If you're wondering where the little picture comes from, it's usually up to you to create your own, appropriate to your application. My Draw painting program is one good way of doing this, here's a shot captured when editing an icon for one of my freeware games:
Back in the code, note the different lines within the APP...ENDA section. Each of them tells the SIBO operating system a little more about how your program is required to work:
The end result is impressively professional. Go back to the system screen and try creating new RMREvent files, switching them (selecting one while another is still running) and deleting them. It's not magic, but it's fairly close. And together we're going to examine the code in detail and discover how it works!
An aside before signing off for this week. Make sure you have a good OPL/16 reference book handy for the next few weeks. It's essential (even for experienced programmers) to have a reminder of the different parameters that each command takes. I use EMCC's "Programming Psion Computers" book, but you can also use the old Psion OPL programming manual, which is over £20 cheaper.
See you next week!
Go to next lesson | Programming index