It is now necessary to create a few constants that link some system resources into our project. We will also change a few previously defined constants to represent data specific to our project, and we will create constants for each graphic widget so that we can refer to named constants instead of the ID numbers defined in the resource file.
Open the Constants browser by clicking on
Tools -> Constants browser
. The constants are listed in categories which are named in the left-hand pane. Clicking on a category will populate the right-hand pane with the constants defined in that category. Clicking on one of the constants will put the value of the constant in the bottom editor pane. Changes to the value must be accepted by selecting "Accept" from the context menu, or pressingCtrl-S
.We first will add constants to the "Resource Databases" category. To do this, select
Constants -> Add resource database...
. You will be presented with a standard Windows file dialog. The first resource database we will add is the main virtual machine. It is a file calledvm-math.prc
, and it is located in the main PST install directory. (There is also a "vm.prc" that you should use if you don't need to do calculations on double values.) Next, we need to add the compiled resources from the last section. To do this, once again selectConstants -> Add resource database...
, and navigate to your project directory. Click on the "Files of type" drop-down list at the bottom and select "PalmOS Resources (*.bin)". You should then see the three .bin files that were generated by the resource compiler. Double-click on any of these. The full path to this file will be placed in the editor pane of the browser. You should select the filename part of it, and change it to a "*". For example, if the editor shows'C:\PocketSmalltalk\ManHourCalculator\tFRM0518.bin'
, replace "tFRM0518" with "*". This will import all files that end in .bin. Otherwise you would have to create a constant for each file. Accept your change by typingCtrl-S
. After performing these steps you should see something looking like this:![]()
We will now create a category of constants called "Widgets", which will contain constants for the graphic widgets we created in our resource file. To do this, right-click in the left-hand pane and select "Add category...". In the box that you are presented with, type
Widgets
and hit the OK button. Now right-click in the right-hand pane and select "New constant...". In the box that pops up, type inMainMenu
and press OK. You will notice that there is an entry in the right-hand pane that says "##Mainmenu", and the editor pane says "nil." Select "nil" in the editor, and change it to1313
. Then accept the change. You need to do this for each of the widgets we created in our resource file. Here is what I used:MainMenu 1313 AboutMenuItem 1314 ExitMenuItem 1315 MainForm 1304 CalcButton 1305 HourField 1307 PopupTrigger 1309 PopupList 1310 AdjustedField 1312 AboutForm 1004You can create constants for the labels in our application, but there is no reason to do this unless you need to reference one of them directly. Having them defined in the resource file is enough to make them show up on the Palm screen.
We will now change one of the system constants to make it specific to our project. Click on the "System Properties" category, then click on the
##applicationTitle
constant. Change "Smalltalk App" to "ManHour Calc". This will be the name that shows up in the Palm application launcher once we load our completed program. Accept your change, and then right-click on the constant in the right-hand pane. From the context menu, select "Change package...". A window will open displaying all of the packages in this project. Select "ManHourCalculator.st" and press the OK button. This will cause our version of the constant to be saved in our custom package.Now close the Constants browser and re-save your project. We are now ready to start writing code.