Please excuse my ignorance but I am just learning to use Code Warrior for Palm
and having all sorts of difficulties in using C with Palm.
I have spent a frustrating week on trying to get data from MemoPad to display a
record in a text field.
I have got some ideas out of the Memo example supplied by Palm and modified an
Errand example to display just one form with a field, namely the first field.
This code should work but it doesn't.
void PutTextForDay(FormPtr frmP) {
UInt16 attr;
MemHandle recH;
FieldPtr fld;
fld = FrmGetObjectPtr (frmP, FrmGetObjectIndex (frmP, ViewErrandField));
DmRecordInfo (kDBName, CurrentRecord, &attr, NULL, NULL);
/*MemHandle*/ recH = DmQueryRecord(kDBName, CurrentRecord);
ErrFatalDisplayIf ((! recH), "Bad record");
FldSetTextHandle (fld, recH);
FldDrawField (fld);
}
It compiles OK but crashes on POSE with an error 'app just read from memory
location 0x00004D79, causing an address error.
An �address error� means that the application accessed a 2- or 4-byte value at
an odd (i.e., not even) memory address.
This happens after DmRecordInfo. I have some advice that I should use MemHandle
on the next line but if I uncomment MemHandle on the next line I get syntax
error.
After playing with this code a bit I discovered that if I have this:
void PutTextForDay(FormPtr frmP) {
UInt16 attr;
FieldPtr fld;
MemHandle recH = DmQueryRecord(kDBName, CurrentRecord);
fld = FrmGetObjectPtr (frmP, FrmGetObjectIndex (frmP, ViewErrandField));
then I don't get a syntax error.
So my question is this:
Is:- MemHandle recH;
recH = DmQueryRecord(kDBName, CurrentRecord);
the same as:-
MemHandle recH = DmQueryRecord(kDBName, CurrentRecord);
Sorry if I have not explained this very well but there seems to be a lack of
information on how to assemble a lot of the code for Palm OS.
The Palm OS Reference is extremely cryptic and the samples are sparse.
Regards,
Barry
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/support/forums/