Palm OS Programming With NSBasic (cont.)
Let's Write Some Code
Now that we have our basic GUI out of the way, it's time to get to the writing of the code. First, let's take care of
the events associated with clicking on our check boxes. A double-click on any object will open a code window where
we can place code associated with the click event for the object. It should be noted that the sub object1011() and the
end sub do not need to be typed as they are placed by NSBasic. Your object numbers may be different from those displayed here,
but you shouldn't worry about this detail.
Type the following code into the window, and we'll look at it in greater detail.
Listing 1
sub object1011()
If (chkRectangle.status=1) then
chkCircle.status = nsbUnchecked
endif
end sub
The code is executed when the Rectangle checkbox is clicked on. It's only real function is to set the corresponding
Circle checkbox to unchecked if it is now checked. Listing 2 displays the opposite code for the Circle checkbox click event.
Listing 2
sub object1012()
If (chkCircle.status=1) then
chkRectangle.status = nsbUnchecked
endif
end sub
The last screen object we need to deal with is the Clear button, which will be used to clear our display area.
Listing 3 contains the complete code necessary to erase the graphics and then redraw them, which results in the clearing of the screen.
Listing 3
sub object1006()
EraseWindow("")
Redraw
end sub
Next: Pen Events