Programming for Palm OS/C/Databases

to open a database
UInt16 cardNo = 0; LocalID databaseId = DmFindDatabase( cardNo, "YourAppDB"); if ( databaseId) {   UInt16     mode = dmModeReadOnly; DmOpenRef database = DmOpenDatabase( cardNo, databaseId, mode); }

to close a database
if ( database) {   Err  e = DmCloseDatabase( database); }

to walk the records of a database
UInt16 numRecords = DmNumRecords( database); UInt16 recordIndex; for ( recordIndex = 0; recordIndex < numRecords;  ++ recordIndex) {   MemHandle  record = DmQueryRecord( database, recordIndex); if ( record) {     UInt32  recordSize = MemHandleSize( record); char   *data = MemHandleLock( record); Err    e = MemHandleUnlock( record); } }

to create databases on your workstation
sudo apt-get install ruby  rubygems sudo gem install --include-dependencies --no-rdoc --no-ri palm


 * 1) !/usr/bin/env ruby

require 'rubygems' require 'palm'

pdb = Palm::PDB.new pdb.name   = 'YourAppDB' pdb.creator = 'Anon' pdb.type   = 'DATA' pdb.version = 1 pdb.data << Palm::RawRecord.new( 'Hello') pdb.data << Palm::RawRecord.new( 'World') pdb.write_file 'YourAppDB.pdb'