Perhaps I'm overly enthused about getting started...

I had hoped that a database would be a fairly simple
place to start that would permit me to avoid basic questions.
(I've stored structures under Borland Builder
with no problem using some basic routines I wrote incorporated
into header files using stream class functions.)
To date, I've gotten PILRIC to generate some basic
code that doesn't refuse to run, and made some simple
modifications.  I've never had
to use the switch construct before, and it's never
been an issue.  It's throwing me off a bit.  (Another
area of needed study.)  The manner in which menu's are
written by PILRIC seems a bit odd, or cumbersome,
as it seems that some code is being repeated, and
I have only one (non-"about") form.

Without an understanding of how to store and
recall data, I was disinclined to continue, as there would
be no capability for any serious programming.

Thanks for responding.  I admit that I have a long way to
go.  After the first few evenings with CodeWarrior,
I was inclined to pursue another approach
using the PalmOS development
IDE that is available that provides VB-like
functionality.  I decided to try to stick it out with
CodeWarrior largely because I had already spent the
money for it, and hoped it might give me more
capabilities in the long run.



----- Original Message ----- 
From: "Robert Moynihan" <[EMAIL PROTECTED]>
To: "Palm Developer Forum" <[email protected]>
Sent: Sunday, October 09, 2005 11:27 AM
Subject: Re: Structure of structures


> Del Ventruella wrote:
>
> >Is the corresponding load sequence:
> >
> >void LoadData(DmOpenRef db, myStructType *myStructP){
> >    MemHandle   recH=NULL;
> >    UInt8      *recP;
> >    UInt16   recIndex=-1;  //will save the data in a new record at the
> >end of the database
> >
> >    RecH=DmNewRecord(db, recIndex, sizeof(myStructType));
> >    if (recH){
> >        recP=MemHandleLock(recH);
> >        DmRead(recP,0,myStructP, sizeof(myStructType));
> >    }
> >}
> >
> >?
> >
> >
> Nope.
>
> You have to FIND the record first, and instead of the DmNewRecord (which
> CREATES a new database record) you will probably want to use a
> DmQueryRecord() command.  When you save the record you will need to tag
> it with some kind of identifyer so that you can find it again.  You
> could put an "id" field in your structure, or you could simply declare
> that 2 first bytes of the database record as an identifier (a UInt16
> unique number), or you could just keep track of the record index in some
> other way (your preferences for the app?)
>
> Once you have found the record you will then access it (DmQueryRecord,
> or DmGetRecord).  Like so:
> MemHandle   recH=DmQueryRecord(db, recIndex);
>
> ... then read the data.  You can read the data directly, by assigning a
> pointer, of the same structure type, to the memory location where the
> stored data is. Like this:
> myStructP=MemHandleLock(recH).
>
> now you can access the saved structure data directly using that pointer.
>
> >One other question, the part about saving the pointer data.
> >
> >The pointer contains the address of the data.
> >
> >Under PalmOS, there is no hard drive where this data safely resides.
> >
> >
> Well, databases are in storage memory, where they are 'safely' stored
> unless your battery loses power.  Pointers are in dynamic memory, where
> they can be easily overwritten, unless you have left them locked..
>
> >If the address is overwritten, you lose the data.  Okay, that I
understand.
> >
> >How does one store (and load) this pointer data
> >
> >in a manner that will insure that it is retained?
> >
> >
> You would store the pointed-to information in your database, perhaps at
> the end of the structure, or as a separate record.  There is no
> hard-and-fast rule as to how to do this.
>
> I get the impression that what you need to do is to study some of the
> example code that is provided with the SDK and tools.  These will be
> very instructive.
>
> Bob.
>
>
> -- 
> For information on using the PalmSource Developer Forums, or to
unsubscribe, please see http://www.palmos.com/dev/support/forums/
>

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

Reply via email to