Hi all!

I try to get some data from a database and put it in two variabels(id and 
name).
But when I call the load state I get the following message:

CTR just read from memory location 0x00000006,
which is low memory.

"Low memory" is defined as the first 256 bytes of memory. It should not be 
directly accessed by applications under any circumstances.

I know that there is one record in the database, but I just can't get it!

Would be very grateful if some of you could lock thrugh the following 
code-snippet and tell me if I got something wrong! Thanks in advance //Maria

Err ResourceHH::loadState()
                {
                        UInt16 maxIdLength=4;
                        UInt16 maxNameLength=20;

                        dbPtr = 
DmOpenDatabaseByTypeCreator('F','ZMgd',dmModeReadWrite);
                        UInt16 index = dmMaxRecordIndex;

                        // Open the record for reading:
                        MemHandle h = DmQueryRecord(dbPtr, index);
                        // Make sure we got a good memory handle:
                        if(!h)
                                return 1;
                        else
                        {
                                // Lock the handle, so we can read from it:
                                Char *i = (Char *) MemHandleLock(h);
                                // Get the length of the id - we can use StrLen since 
the name
                                // is stored like a regular null-terminated string:
                                UInt16 iLen = StrLen(i);
                                // The name is stored immediately after the id:
                                Char *n = i+iLen+1;

                                // Now copy the two strings, and make sure they are 
null-terminated:
                                StrNCopy(id, i, maxIdLength);
                                id[maxIdLength-1] = 0;
                                StrNCopy(name, n, maxNameLength);
                                name[maxNameLength-1] = 0;

                                // Remember to unlock the handle now that we're done 
with it:
                                MemHandleUnlock(h);
                        }

                // Everything went smoothly:
                return 0;


                }

_________________________________________________________________
H�mta MSN Explorer kostnadsfritt p� http://explorer.msn.se


-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/tech/support/forums/

Reply via email to