Hey folks,

I desperately need a little debugging help.

Can anyone tell me why this would bomb (Fatal Exception)? Here's the 
struct and then the code fragment...

struct tDocRecord0 {
    byte  crap;          // because of some flaw in some docs.
    byte  wVersion;      // 1=plain text, 2=compressed
    WORD  wSpare;
    DWORD dwStoryLen;    // in bytes, when decompressed
    WORD  wNumRecs;      // text records only; =tDocHeader.wNumRecs-1
    WORD  wRecSize;      // usually 0x1000
    DWORD dwSpare2;
};

Boolean SaveEBook(UInt16 cardNo, char *Filename, UInt32 length)
{
     VoidHand  RecHandle;
     Ptr RecPointer;
     struct tDocRecord0 *theRec;
     Err theErr;
     LocalID db;

     theErr = DmCreateDatabase(cardNo, Filename, 'REAd', 'Deep', 
                               false);
     if (theErr == errNone) { 

           if (db) zDB = DmOpenDatabase(cardNo, db, dmModeReadWrite);
           else {
               FrmCustomAlert(DebugAlert, "Couldn't find db!",0, 0);
               return(false);
           } 

           if (zDB == NULL) return(false);

           theRec->wVersion = (byte) 1
           theRec->dwStoryLen = length;  // <= Bombs here.
           theRec->wNumRecs = (WORD) 2;      
           theRec->wRecSize = (WORD) 4096;     
           theRec->crap  = (byte) 0;
           theRec->wSpare  = (WORD)0;
           theRec->dwSpare2  = (DWORD)0;
           
           ...

It is bombing right at the "theRec->dwStoryLen = length;" moment. 
I've tried casting it as "theRec->dwStoryLen = (DWORD) length;" as 
well. Both Fatal Exception on me if the length is greater than 1000 
(1024?) or so. (Well, I've seen it succeed at 600, 800 or so, and 
then explode every time at 1400 or so.) I keep thinking there must be 
something else going on, but my debugging attempts so far only narrow 
down to this point! Am I doing something stupid??? (I must be, but 
dang if I can figure it out.)

This one bug is driving me insane! Aaaaaagggg--kkk!

Thanks in advance,
zane
-----
r. zane rutledge [EMAIL PROTECTED]
www - http://www.rzanerutledge.com/palm/

-- 
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