Sunit Katkar's Home Page

 Palm Tutorial:



 Palm Links:
 


What you need to have before you start this tutorial:

I have used Metrowerks Code Warrior Rel. 5 with the Palm 3 running on Palm OS 3. for development. For actual testing and debugging I have used a Palm Pilot 3.

Many wrote to me about problems they were facing while running the application using a Palm Emulator software(POSE). I have not tried it with POSE and hence cannot help you there. Sorry about that.

Though some of the event handling, include files and resources may be specific to Code Warrior, the source code is fairly simple. If you are using Code Warrior or any other tool, please do the following:

Create a simple application with 3 forms. You may give any names to the forms and the subsequent GUI elements.

On:

  • form 1 there is a list object, a checkbox, and a button

  • form 2 there are two text fields with appropriate labels, a Back button and a Next button

  • form 3 there is a single text field with an appropriate label, a Back button and a Save button.

Application Functionality:

The application works in the following fashion -

  • There is a null terminated text string stored as a record in the database of the Palm.

  • The application starts with main form having a List object to list all the records in the database

  • There is a New Record button to allow the user to create a new record

  • If any records exist, the user can tap on the List and Edit the record

    • Tapping a particular record in the list causes that record to be read and and appropriate text fields to be filled in on both forms.

    • This then opens the form 1 with the text fields filled with the appropriate text from the record

    • The text field on form 2 also has the appropriate text filled int he text field

  • On clicking the New Record button, the user is presented with form 1

  • The user fills in text in the two fields on form 1 and clicks the Next button to go to form 2

  • On form 2 the user enters text in the third text field.

  • From form 2 the user can go 'Back' to form 1 to modify some text and come back to form 2

  • On form 2 the user can Save the record

  • A maximum of 50 characters can be entered in each text field for the sake of this example

Application Design:

The application is designed in the following fashion -

A user may create a new record or simply decide to edit an existing record. There is a main form where the application starts. The user starts either creating a new record or editing an existing one from this form.

Case 1: The user wants to create a new record

The user will click on the New Record button. This will start the event handling code and will present the user with form 1. Now there is a form open event - frmOpenEvent - which does initialization, if any, of the form before drawing - FrmDrawForm(FormPtr frm) - it. If a new record is being created then the text fields on form 1 just need to be set to show no text.

A custom function sets the text in a text field -SetFldText(Word objectID, CharPtr pszBuf, Boolean bClearField ) - which takes the following arguments : the objectId of the text field object, a char pointer to the string you want to set and a boolen which decides whether you want to first delete the existing contents and redraw them.

Now after the text fields are filled with text, the user clicks on the Next button, which will present form 2 to the user. But before this happens, the text in the two text fields on form 1 must be saved temporarily somewhere in memory. Similarly if the user enters text in text field on form 2 and decides to come back to form 1 for some modification or just like that, then the text in form 2 must also be saved temporarily somewhere in memory.

On opening form 1, the text saved earlier on, must be read and set as the text in the two text fields. If the user modifies the text on form 1 and goes ahead to form 2, then again the existing text in fields on form 1 must be saved and so on.

Finally on form 2 the user clicks the Save button and saves the record. Before we hand over all the strings to the Palm OS DataManager to save as a record we need to process these strings. These separate strings need to be combined as a single null terminated string. Then it must be presented as a single string to the Palm OS DataManager. After this string is stored as a record, the user is then taken to the main form where he can see the just created record in a list.

Case 2: The user wants to edit an existing record

For this the user taps a particular record displayed in the list. We have to determine - LstGetSelection (ListPtr ListP) - which record was tapped upon.

We must then read that record from the database and read the null terminated text string. Next, break up this string into separate strings and finally populate the fields on each form accordingly.

Once this is done the user must be allowed to go to and from between form 1 and form 2 to modify any text.

Then finally when the user clicks the Save button, we have to remove or erase the current record and rewrite this newly modified record in its place.

Main |  1 |  2 |  3 |  4 |  5 |  6