Palmphi
Databases (TPalmDB)
TPalmDB is not intended as a replacement
of the API. You can do the basic functions with it, but if you want something
more you will have to learn to use the api or teach me so I can improve parser.c.
1. Opening a database.
To open a data base use the method openR or openRW depending on the access rights you want :
TPalmDB myDB;
myDB.OpenR('iddb');
iddb is the id of the database. This id is specified when creating the database:
if (!myDB) myDB.Create("My_DB",'iddb');
A database won't be created if it already exists, so normally you would write :
myDB.Create("My_DB",'iddb');
myDB.OpenRW('iddb');
2. Working with a database
2a Reading registers
To read a register of a database use the method Read(idx,buffer,recsize) :
char buffer[1024];
memo.OpenR('memo');
memo.Read(0,buffer,memo.RecordSize(0));
memo.Close();
Edit1.Text=buffer;
This example reads the first memo stored in your memo pad (because we used
the id 'memo') and copies its contents to the Edit1 component. Edit1 should
be Multilined to display the whole content. The variable buffer should be
big enogh to contain the whole text.
Every register in the database can have a different size. For every operation on a register you must specify the register size.
You can get the register size by calling RecordSize(idx). The argument of
this method is the index of the register. Use this function if you are not
sure of the size of the argument.
2b Inserting registers
To insert a new register use the function Insert(idx,buffer,recsize). The next code inserts a new memo in the position 0 :
memo.OpenRW('memo');
memo.Insert(0,"hello Memopad",14);
memo.Close();
2c Replacing registers
To replace the contents of a register use the function Modify whose parameters have the same meaning as in read and insert.
2d Remove registers
To remove a register use the method Remove(idx).
3. Backing up your database
To mark your DB for be backed up then next time you synchronize use the BackupDB property :
myDB.BackupDB=1;