Slide 10.7: Palm OS databases (cont.)
  Slide 10.9: Database demonstrations (cont.)
  Home


Database Demonstrations


The following emulator screen dumps show the interface generated by the next application DB.
  1. Go to Screen B after clicking on DB icon.

    Note that the default icon is used because the .xrd file without images will be used to build the project.
  2. This form shows the main interface, which includes six fields, nine buttons, four checkboxes, and a menu bar.

    Go to Screen C after clicking on the + button.

  3. This is the form for inserting a record.
  4. This is the Edit menu, which provides users to copy/cut/paste/ ... fields.
  5. This is the Options menu, which includes Help and About items.

Before the Palm OS Resource Editor, you have to manually create the following C header file DB.h and Palm OS resource file DB.rcp for the above interface:

 DB.h 

#define  MainForm              1000
#define  MainUniqueID	       1001
#define  MainName              1002
#define  MainQuantity          1003
#define  MainAttrDelete	       1004
#define  MainAttrDirty	       1005
#define  MainAttrBusy	       1006
#define  MainAttrSecret	       1007
#define  MainUpdate            1010
#define	 MainDelete	       1011
#define	 MainLock              1012
#define	 MainUnlock	       1013
#define	 MainFirstRec	       1020
#define	 MainPrevRec	       1021
#define	 MainCursor	       1022
#define	 MainNextRec	       1023
#define	 MainLastRec	       1024
#define	 MainInsert	       1025
#define	 MainDataBytes	       1030
#define	 MainTotalBytes        1031

#define  InsertForm	       2000
#define	 InsertName	       2001
#define	 InsertQuantity	       2002
#define	 InsertOK              2003
#define	 InsertCancel          2004

#define  MainMenu              1000
#define	 MainEditClearCmd      1010
#define	 MainEditCutCmd        1011
#define	 MainEditCopyCmd       1012
#define	 MainEditPasteCmd      1013
#define	 MainEditSelectAllCmd  1014
#define	 MainOptionsHelpCmd    1020         
#define	 MainOptionsAboutCmd   1021

#define	 HelpAlert             1000
#define	 AboutAlert	       1001
#define	 RomIncompatibleAlert  1002
#define	 ErrorAlert            1003


 DB.rcp 

#include "DB.h"

FORM ID  MainForm AT (0 0 160 160)
USABLE
MENUID  MainMenu
BEGIN
  TITLE  "Database"

  BUTTON "\003" ID  MainFirstRec  AT (CENTER@40  20 AUTO AUTO) FONT 3 NOFRAME
  BUTTON "\002" ID  MainPrevRec   AT (CENTER@60  PREVTOP AUTO AUTO) FONT 4 NOFRAME
  FIELD         ID  MainCursor    AT (CENTER@80  PREVTOP 20 AUTO) LEFTALIGN NONEDITABLE MAXCHARS 5
  BUTTON "\003" ID  MainNextRec   AT (CENTER@100 PREVTOP AUTO AUTO) FONT 4 NOFRAME
  BUTTON "\004" ID  MainLastRec   AT (CENTER@120 PREVTOP AUTO AUTO) FONT 3 NOFRAME
  BUTTON "+"    ID  MainInsert    AT (CENTER@140 PREVTOP AUTO AUTO)

  LABEL "Unique ID: " AUTOID AT (RIGHT@70 PREVBOTTOM+8) FONT 1
  FIELD ID  MainUniqueID AT (PREVRIGHT PREVTOP 50 AUTO) RIGHTALIGN DISABLED
    NONEDITABLE UNDERLINED MAXCHARS 10 NUMERIC 

  LABEL "Name: " AUTOID AT (RIGHT@70 PREVBOTTOM+4) FONT 1
  FIELD ID  MainName AT (PREVRIGHT PREVTOP 80 AUTO) LEFTALIGN EDITABLE
    UNDERLINED MAXCHARS 20

  LABEL "Quantity: " AUTOID AT (RIGHT@70 PREVBOTTOM+4) FONT 1
  FIELD ID  MainQuantity AT (PREVRIGHT PREVTOP 20 AUTO) RIGHTALIGN EDITABLE
    UNDERLINED MAXCHARS 4 NUMERIC 

  LABEL "Attributes: " AUTOID AT (RIGHT@70 PREVBOTTOM+4) FONT 1
  CHECKBOX "Delete" ID  MainAttrDelete AT (PREVRIGHT PREVTOP 44 AUTO) DISABLED
  CHECKBOX "Dirty"  ID  MainAttrDirty AT (PREVRIGHT PREVTOP 44 AUTO) DISABLED
  LABEL "" AUTOID AT (RIGHT@70 PREVBOTTOM+1) FONT 1
  CHECKBOX "Busy" ID MainAttrBusy AT (PREVRIGHT PREVTOP 44 AUTO) DISABLED
  CHECKBOX "Secret" ID  MainAttrSecret AT (PREVRIGHT PREVTOP 44 AUTO)

  BUTTON "Update" ID  MainUpdate   AT (2	        PREVBOTTOM+8 AUTO AUTO)
  BUTTON "Delete" ID  MainDelete   AT (PREVRIGHT+2  PREVTOP      AUTO AUTO)
  BUTTON "Lock"   ID  MainLock     AT (PREVRIGHT+2  PREVTOP      AUTO AUTO)
  BUTTON "Unlock" ID  MainUnlock   AT (PREVRIGHT+2  PREVTOP      AUTO AUTO)

  LABEL "Data Bytes: " AUTOID AT (4 PREVBOTTOM+8)
  FIELD ID  MainDataBytes AT (PREVRIGHT PREVTOP 30 AUTO) DISABLED NONEDITABLE MAXCHARS 5
  LABEL "Total Bytes: " AUTOID AT (84 PREVTOP)
  FIELD ID  MainTotalBytes AT (PREVRIGHT PREVTOP 30 AUTO) DISABLED NONEDITABLE MAXCHARS 5
END

FORM ID  InsertForm AT (5 40 150 80)
FRAME MODAL USABLE
BEGIN
  TITLE "Insert Record"

  LABEL "Name: " AUTOID AT (RIGHT@60 20) FONT 1
  FIELD ID  InsertName AT (PREVRIGHT PREVTOP 80 AUTO) LEFTALIGN EDITABLE UNDERLINED MAXCHARS 20

  LABEL "Quantity: " AUTOID AT (RIGHT@60 PREVBOTTOM+4) FONT 1
  FIELD ID InsertQuantity AT (PREVRIGHT PREVTOP 20 AUTO) RIGHTALIGN EDITABLE 
    UNDERLINED MAXCHARS 4 NUMERIC 

  BUTTON "OK" ID InsertOK AT (CENTER@50 PREVBOTTOM+8 AUTO AUTO)
  BUTTON "Cancel" ID InsertCancel AT (CENTER@110 PREVTOP AUTO AUTO)
END

MENU ID  MainMenu
BEGIN
  PULLDOWN  "Edit"
  BEGIN
    MENUITEM  "Clear"ID MainEditClearCmd"L"
    MENUITEM  SEPARATOR
    MENUITEM  "Cut"	ID MainEditCutCmd"X"
    MENUITEM  "Copy"	    ID MainEditCopyCmd"C"
    MENUITEM  "Paste"	    ID MainEditPasteCmd"V"
    MENUITEM  SEPARATOR
    MENUITEM  "Select All"ID MainEditSelectAllCmd"S"
  END

  PULLDOWN  "Options"
  BEGIN
    MENUITEM  "Help"ID MainOptionsHelpCmd"H"
    MENUITEM  SEPARATOR
    MENUITEM  "About" ID MainOptionsAboutCmd"A"
  END
END

ALERT ID  HelpAlert
INFORMATION
BEGIN
  TITLE "Help"
  MESSAGE "This app provides a database that you can browse using buttons and hard keys. "\
    "You may add, update, delete, lock/unlock or hide/show ('Secret') records. "\
    "Changes made to records ARE saved!\n"
  BUTTON "OK"
END

ALERT ID  AboutAlert
INFORMATION
BEGIN
  TITLE "About Database"
  MESSAGE "This is a demonstration of database programming for PalmOS."
  BUTTON "OK"
END

ALERT ID  RomIncompatibleAlert
ERROR
BEGIN
  TITLE "System Incompatible"
  MESSAGE "System Version 2.0 or greater is required to run this application."
  BUTTONS "Ok"
END

ALERT ID  ErrorAlert
ERROR
BEGIN
  TITLE "Error!"
  MESSAGE "^1\n^2\n^3"
  BUTTONS "Ok"
END

VERSION 1  "1.0.0"
LAUNCHERCATEGORY ID  1000 "Tutorial"