//This is a routine that deals with a database and two fields
//It updates the both fields from the record found from the
//database which might look like "town-tabchr-city"
//first field will have town inserted
//second field will have city inserted
//You can modify snippet to suit your requiremjents
static void ActionLoadRecords (FormPtr frm)
{
UInt16 MyField;
MyField = ActionPrevField;
RecordToField (frm, index, MyField);
index ++;
MyField = ActionDestField;
RecordToField (frm, index, MyField);
index--;
}
static void RecordToField (FormPtr frm, UInt16 index, UInt16 MyField)
{
FieldPtr flc;
MemHandle h;
Char* p = NULL;
WChar outChar;
UInt32 inOffset;
UInt16 b;
UInt16 len;
Char* bilum;
MemHandle oldText;
MemHandle newText;
h = DmQueryRecord(CrawlDB, index-1);
p = MemHandleLock(h);
len = StrLen(p);
b=0;
inOffset=0;
while (inOffset<len)
{inOffset += TxtGetNextChar(p, inOffset, &outChar);
if (outChar != commaChr)
{b++;}
else break;
}
MemHandleUnlock(h);
len = b;
flc = FrmGetObjectPtr (frm, FrmGetObjectIndex (frm, MyField));
oldText = FldGetTextHandle(flc); //get old text
if (oldText)
{
FldSetTextHandle(flc, NULL);
}
newText = MemHandleNew(len+1);
bilum = MemHandleLock(newText);
StrNCopy(bilum,p,len);
bilum[len]= '\0';
FldSetTextHandle (flc, newText); //set new text
MemHandleUnlock(newText);
if (oldText != 0)
MemHandleFree(oldText); //free old text
FldDrawField(flc); //redraw field
FldReleaseFocus(flc);
}
--
For information on using the PalmSource Developer Forums, or to unsubscribe,
please see http://www.palmos.com/dev/support/forums/