SiteInfo is a structure variable.  I'm still getting hardware error #3 when
I try to exit the program with the message indicated.  I can push "save",
trigger the save from "whats in" Record to the SiteInfo structure, call the
appinfo write function, then continue to navigate within the program.

----- Original Message ----- 
From: "Dean Gahlon" <[EMAIL PROTECTED]>
To: "Palm Developer Forum" <[email protected]>
Sent: Tuesday, November 22, 2005 2:17 PM
Subject: Re: APPINFO BLOCK??? HARDWARE ERROR #3?


> On Tue, 22 Nov 2005, Del Ventruella wrote:
>
> > I have a structure that contains data entered from a form.  I want to
first put data into that structure from an AppInfo block, although I don't
know how to determine if anyone has filled in the data yet.  I have written
a function to put data into an AppInfo block, and it seems to run, but I get
hardware error #3 when I exit the program.  I had it running with no errors
before I decided to store a structure in the appinfo block of the database.
> >
> > I begin by putting data into the structure (Record is the name) that is
used to fill the fields on the form from a global structure variable
(SiteInfo) that I fill in with a fixed data set:
> >
> > Record = *SiteInfo;
> >
> > If someone pushes the "Save" button, I read the fields on the form and
save the results in Record.  I then save the contents of Record in SiteInfo.
SiteInfo is the structure to which the function to write to the appinfo
block looks for the data to put in the appinfo block:
> >
> > SiteInfo=*Record;
>
> Without seeing what the definitions of these two structures are (HINT:
> many times, seeing just the code provides insufficient information to see
> what's going on), I can't be sure, but these two statements seem
> contradictory. If 'Record' is a structure variable, and 'SiteInfo' is a
> pointer to a structure of that type, the first statement will work but the
> second won't. If 'Record' is a pointer variable and 'SiteInfo' is a
> structure variable, the second statement will work and the first won't.
> I'm not sure how you can have both statements in the same program,
> referring to the same variables, and have them both work.
>
> Unfortunately, I don't have answers about storing data into the
> AppInfoBlock, since if I've done that, it's been quite a while. My only
> question about the code below where you write into the appinfoblock hinges
> on how the variable 'SiteInfo' was defined. If it was defined as a
> structure variable, I'd think the code should work to write the data
> that's in that variable into the appinfo block. If 'SiteInfo' was defined
> as a pointer variable, the code will only write 4 bytes of the pointer
> into the appinfoblock, which probably isn't what you want.
>
>
> >
> > I then call the function to write to the appinfo block:
> >
> > err = CreateAppInfoBlockForDB(gTransformer);
> >
> >
> > The function to write to the appinfo block is:
> >
> > Err CreateAppInfoBlockForDB(DmOpenRef db)
> > {
> > UInt16 cardNo;
> > LocalID dbID;
> >
> > MyAppInfo *appInfoP;
> > Err err;
> > MemHandle h;
> > //filled in by me
> > cardNo = 0;
> > dbID = '!!$g';
> >
> > //end of filled in by me
> >
> >
> > TransformerDbaseCreate();
> >
> > //DATABASE HAS TO BE OPEN!!! IT'S NOT OPEN TILL YOU OPEN THE TRANSFORMER
FORM!!!
> >
> >
> > err = DmOpenDatabaseInfo(gTransformer, &dbID, NULL, NULL, &cardNo,
NULL);
> > if (err !=errNone)
> > return err;
> >
> >
> > h = DmNewHandle(db, sizeof(MyAppInfo));
> > if (!h)
> > return dmErrMemError;
> >
> > appInfoID = MemHandleToLocalID(h);
> > err= DmSetDatabaseInfo(cardNo, dbID, NULL, NULL, NULL, NULL, NULL, NULL,
NULL,&appInfoID, NULL, NULL, NULL);
> >
> > if (err==errNone)
> > {
> > appInfoP = (MyAppInfo*)MemHandleLock(h);
> >         //err = DmSet(appInfoP, 0, sizeof(MyAppInfo), 0);//clear all
fields
> > err = DmWrite(appInfoP, 0, &SiteInfo, sizeof(SiteInfo));
> >
> > MemPtrUnlock(appInfoP);
> >
> > }
> > else
> > {
> > MemHandleFree(h);
> > }
> >
> > err = DmCloseDatabase(gTransformer);
> >
> > return err;
> > }
> >
> >
> > I need some way to always get the data in SiteInfo to correspond to what
is in the appinfo block, so I can always be sure that what is place into
record and loaded onto the form when the form is loaded is the saved data,
even if the user has left the application.  To do this, I need to be able to
determine if there is anything in the appinfo block of a database, and if
so, copy its contents into the structure, Record.  If not , I need to copy
the contents of the appinfo block into Record as they originally exist
before the database is created and the site data is saved using the "Save"
button.
> >
> > Can anyone show me how to:
> >
> > 1.  Determine if the appinfo block has data in it?
> > 2.  Read the contents of the appinfo block into Record?
> > 3.  Save the contents of Record in the AppInfo Block?
> >
> > I had been trying to set the SiteInfo pointer to Record to make sure
that what was in Record gets saved.  I run into a problem when I try to
close with the following error.  Otherwise, I get no errors when running the
software.  As I said, I had no error messages before I attempted to add this
appinfo block data:
> >
> > "Hardware exception #3 occurred while th eemulator was calling the Palm
OS function "DmOpenDatabaseInfo".  The emulator is now in an unstable state
and will reset."
> >
> > Thanks for your help!
> > --
> > 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/
>

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

Reply via email to