Please excuse me, I am sure this question has been asked many times, but I
have looked and have not found a simple database example. I have the book
from O'Reilly and have been learning everything from it. I have successfully
created my database and added a record, however I am having difficulties
retrieving the record, I get garbage.

I viewed my datafile with a utility that I found on the net, and the record
was added correctly so it's in my read code. In short, here is the code that
is not working.

// Packed Ham Structure
typedef struct
{
        SDWord          hamID;
        char            name[1];                // actually may be longer than 1
} PackedHam;

// Unpacked Ham Structure
typedef struct
{
        SDWord          hamID;
        const char *    name;
        const char *    callSign;
        const char *    notes;
} Ham;

static void UnpackHam(Ham * ham, const PackedHam * packedHam)
{
        const char *s = packedHam->name;

        ham->hamID = packedHam->hamID;
        s += StrLen(s) + 1;
        ham->name = s;
        s += StrLen(s) + 1;
        ham->callSign = s;
        s += StrLen(s) + 1;
        ham->notes = s;
        s += StrLen(s) + 1;
}

static void EditFormDisplayFirstRecord()
{
        VoidHand                rec;
        Ham                     ham;

        rec = DmGetRecord(HamCallsDB, 0);
        UnpackHam(&ham, MemHandleLock(rec));
        MemHandleUnlock(rec);

        FrmCustomAlert(HamInfo, ham.name, ham.callSign, ham.notes);
        // SetFieldTextFromStr(EditForm_Name, (CharPtr)ham.name);
        // SetFieldTextFromStr(EditForm_CallSign, (CharPtr)ham.callSign);
        // SetFieldTextFromStr(EditForm_Notes, (CharPtr)ham.notes);
}

After everything is up and running, EditFormDisplayFirstRecord() is executed
by pressing a button on my screen, and it fills my fields in with garbage.
The FrmCustomAlert shows nothing.

Can anyone help or point me towards a simple data example?

Thanks!

Jeremy Cowgar - [EMAIL PROTECTED]
Christian Brotherhood Newsletter



-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palm.com/devzone/mailinglists.html

Reply via email to