"KEN" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]
> hi all,
>
> I have no problem retrieve integers, but when I deal with array[]
> (integers), I have no idea how to do
>
>
> typedef struct {
>          Int16    *array;
>          // ....  other stuff
> }    Path;
>
> static readFunction() {
> // .... strip
> Path    *path
>
> recordH = DmQueryRecord(gDB, recordNum);     //Read the record
> path = MemHandleLock(recordH);
>
> arr = path->array                    // here is the problem
>
> MemHandleUnlock(recordH);
>
> }

Ken, what you describe indicates that you don't understand the fundamental
concept of pointers in C.  You have no idea how frequently issues like yours
are brought up in this forum, so you may not get many friendly responses,
but here goes.

Your structure "Path" contains a POINTER to a location in memory, so when
you save it to a database record, you are only saving the value in that
pointer, and NOT the data to which it points.  When trying to store
structures such "Path" in a database, you need firstly to (using a C++ term
here) "serialize" the data.  That is, to convert a complex data set into a
form whereby it can be stored as a sequential set of bytes.  One form of
serialisation used in the inbuilt PalmOS PIM applications (specifically the
Addressbook) is referred to as "packing" and "unpacking".

Please get a good book on C programming, and read it well, focussing on
pointers, the "address of" operator, dereferencing, etc.

Get the sourcecode for the PalmOS PIM apps, and have a look at what I'm
talking about with pack and unpack.

Read up on serialization.

Alan



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

Reply via email to