|
Paul Jones dissects the PDO source code included on the AC#5
Reader Disk...
If you missed AC#5 or the Reader Disk they're both still available as
back issues.
Click here to place an
order...
Lines 1-4
REM statements, short for REMark, enable programmers to add comments to
the source code. The compiler does not compile REM statements. HBASIC
also interprets the ' character as REM.
Line 5
These libraries will be included in our program. Both libraries add GEM
support for accessing menus/dialogs/alerts and so on. Other libraries
enable access to different parts of the operating system, for example
"gemdos", "xbios" and "bios".
Lines 7-8
These are compiler options, a compiler option is accessed using...
REM $option
...followed by the option. The k option reserves memory for the program,
g forces a GEM program, y+ sets the default window (with the title
"Compiled by HiSoft BASIC") off, which otherwise opens automatically).
v+, u+, #, [ and ] respectively sets variable checks on, underlines in
variables, no FNs in libraries, array warnings and allow undefined
sub-programs on.
Line 10
In the first tutorial we covered strings and variables. This function
states every variable with a first letter between a and z will be an
integer variable (INT). In HBASIC this means any whole number in the
range +32767 to -32768. Since all the commands in the GEMAES/GEMVDI
libraries use INTs, this function saves adding the integer % marker to
each individual variable.
Line 12
This enables the variable junk to be SHARED for use anywhere in the
program.
Lines 15-16
This includes the external files PDO.BH and GEMAES.BH. PDO.BH was
created by WERCS and tells us the location of each object in the
resource (RSC) file. GEMAES.BH includes lots of CONSTs (more about these
later).
Line 20
When a RSC file is loaded into memory, GEM sets up each graphic object
with it's little bit of memory. Using the this formula, we can find that
address. This is used with the code below to deselect the button.
Lines 22-26
This deselects an object. When a dialog box is displayed and a button is
clicked, the button remains selected until this subroutine deselects it.
Lines 28-44
This displays a dialog box, rsrc_gaddr finds the dialog box in memory,
form_center centres the box in the current resolution and returns the
location in x,y and the width and height in w and h.
Next form_dial FMD_START tells GEM we want to open a dialog box and
form_dial FMD_GROW draws a "grow box" to the size of the dialog.
The user now interacts with the objects using form_do and the selected
button is deselected by calling the exclob_state subroutine.
The dialog box is closed by drawing a "shrink box" using form_dial
FMD_SHRINK and form_dial FMD_FINISH tells GEM to update any objects
contained within the dialog box area. The GROW and SHRINK form_dial
commands are often omitted by programmers to display dialogs faster but
they do provide useful visual feedback.
Lines 47-70
When the user selects a menu item, the program jumps to this subroutine.
We then check to see which item was selected and do the relevant code.
These names are included in the PDO.BH file, and are actually number
values! Algebra eat your heart out!
Lines 72-80
This subroutine loads the resource file. If the file cannot be found a
warning alert box is displayed, refer to the Warning boxout for more
detail.
Lines 90-98
If the user decides to exit the program this code removes the menu bar
from the current program.
Lines 100-105
Draws the menu bar.
Lines 107-118
If the user selects a menu item this code establishes which menu item
and menu title was selected, and calls the ProcessUserMenu sub program,
intructing it what to do with this information. After the programmer has
done whatever he/she wants in this subroutine (maybe bring up an dialog
box for options), the menu title is deselected.
Line 120
This is a simple loop which waits for a "system message" sent by GEM
informing it something has happened to the program. For example, a
window has been closed, a menu has been clicked on or the user has
selected a button. Check your manuals for detailed information on
evnt_multi.
The latest version of PDO, along with the RSC file and include files are
all included on the Reader Disk.
Click here to order a Reader Disk...
WARNING!
|
The form_alert command displays an alert box, which is a simple way of
communicating with the user and a useful debugging aid during program
development. Alerts take the form:
[icon][message][button1|button2...]
Where [icon] can be in the range 0 to 3. 0 is no icon, 1 displays !, 2
displays ? and 3 displays STOP.
After creating your [message] it is displayed using:
but=FNform_alert (default,text$)
The button pressed is now contained in but. If the user pressed
[return], the default button number would be used. For example:
but=FNform_alert (1,"[2][ Should I
format or delete the hard drive? ]
[ Format | Delete ]")
If the user selects Format, but is set to 1, or 2 if Delete was
selected.
|
EXTRAS
|
The HiSoft BASIC Useful Routines And Documentation Guide is a separate
Specialist Reader Disk compiled by Paul Jones which includes:
- All the previous HiSoft BASIC tutorials, images and source code
- Libraries
- GEMVDI note
- library list
- NetWorld: Enables HiSoft BASIC to connect to the internet using STiK!
Includes Telnet example.
- MODPLAY: DSP560001 library to play MOD files
- WavePlay: Assign sounds to events using SAM Aware Applications (SAA) files via SAM/KP SACK.
- OOPLIB: Object Oriented Programming Library
- Writing your own libraries, with example
- Iconify
- Accessing BubbleGEM, source code and explanation
- VA protocol
- Drag&Drop protocol
- Multitasking extras
- Latest GEMAES.BH file
- PRG Flags
- Other useful routines including, sprite handling, tokenising,
Hex/Oct/Bin/Dec, blind dates and loads of source!
Click here to order this
Specialist Reader Disk...
|
|