Several people have emailed me to comment how strange it is to have a program which initially just shows a blank screen, with no prompt as to what to do next. Quite right, so let's fix it now.
The first (and quickest) thing we can do is add a brief flashed message
in a screen corner. After the WHILE 1 line, add
gIPRINT "Press the Menu key to proceed"
Translate and run and you'll see it flash up. All well and good, but it's gone after a couple of seconds, leaving the blank screen as before. There's nothing wrong with our application being 'menu-driven' but we ought at least to put something up on screen to show that the program hasn't broken! Although most professional programs have one or more main screens of information which form the core of what the user sees, our "MiLo" program is simple enough that we haven't got sufficient information to even partially fill a screen in any kind of relevant way. So we'll fall back on another common technique, the idea of a 'splash' screen.
A Splash screen is a picture or block of information which
The first step is to create a suitable picture/logo etc. This will obviously vary according to whether you're on a Series 5 or Series 3, but essentially you want to create an "EPOC picture" or ".PIC" file of appropriate size (say, 480 by 160 pixels, a size which will work on both machines) and store it in a suitable folder (e.g. the root directory of the default disk).
You'll see my rather half-hearted splash screen attempt above
(I'm no artist!), created in my case in SKETCH on a Series 5 and exported as an
EPOC picture to "front.mbm" in the root directory. Series 3 users can use
DRAW, saving the resulting bitmap in .PIC format in the
same place.
If you're unsure about graphics files and their formats, check out Phil Spencer's and Lieuwe de Vries' excellent web sites, each of which cover (amongst other things) these issues.
Time to load the graphic into our program. In the list of LOCAL
variables at the top of the program, add another, image%.
LOCAL i%,j%,image% rem etc.
Psion's OPL graphics system works on the principle of 'drawables'.
Essentially, every loaded image or graphics window is assigned a number which
acts as a name and can be used to reference the graphic later on. As a special
case, the main screen is drawable no.1, and we're here defining a new drawable
as number image%. Note that we never need to know what number is actually
stored inside image% as OPL handles all that. We just use the image% variable
name.
As you'll imagine we need to insert a few lines of code to make the picture display. The sequence of events is:
Translated into code to be placed just after the DEFAULTWIN line, this
becomes:
image%=gLOADBIT("\front.mbm")
gUSE 1
gAT 0,0
gCOPY image%,0,0,480,160,0
gCLOSE image%
If you're an OPL/16 (Series 3) user, you'll need to use "front.pic" instead, of course! A few other quick notes:
... which, once translated and run, gives:
One last thing: you need to add a new line to the top of the proc
setup: procedure:
gCLS rem Clear the screen
Without this screen-clearing line, the picture will persist on screen, leading to a rather ugly effect!
Make sure you understand the lines of graphics code above, as a basic knowledge of OPL's graphics commands will let you display almost anything in your programs. Pictures, animations, special effects are all within your grasp. It's also worth finding a painting program you're happy with, too and learning how to get the most out of it to create images of a particular size as smoothly as possible. Series 5 users currently have a choice of SKETCH or Photo5, Series 3 users a whole multitude (including Draw, Palmtop Picasso, Perfect Paint, S3aDraw and others).
That about wraps things up for now; why not pop back next week?
Go to next lesson | Programming index