I'm assuming the problem is in GetValue, because I really wrote that off the
top of my head because I didn't know how to grab a piece of data from the
database.  I used the packValue function to add data to the database, and
that seems to run okay.  (can't completely test it because I can't get the
info I put into it to display.... which is what I'm trying to do now :-)

Now, I based this whole packing and unpacking off the O'Reilly Sales
example.  Assuming that one works... it should work for my scenario :-)




void UnpackValue(tblValuePtr value, const tblPackedValuePtr packedValue)
{
     const char *s = packedValue->Strings;
     value->ValueID = packedValue->ValueID;
     value->BeginningValue = packedValue->BeginningValue;
     value->EndingValue = packedValue->EndingValue;
     value->TotalValue = packedValue->TotalValue;
     value->Number = s;
     s += StrLen(s) + 1;
     value->VNumber = s;
     s += StrLen(s) + 1;
     value->Driver = s;
     s += StrLen(s) + 1;
     value->StartDate = s;
     s += StrLen(s) + 1;
     value->EndDate = s;
     s += StrLen(s) + 1;
     value->Origin = s;
     s += StrLen(s) + 1;
     value->Destination = s;
     s += StrLen(s) + 1;
}


ValueID is a UInt
BeginningValue, EndingValue, TotalValue are floats
The rest are Strings

Basically, my methodology was that I'd create a function that called my
"Unpack" function, get the value of the field I needed, returned it so that
I could display it in a Field.  However, I'm not certain of a way to display
floats in the Field box, so I tried to convert the float into a CharPtr for
display purposes.

--

Timothy Astle


McMicken, Steven <[EMAIL PROTECTED]> wrote in message
news:8146@palm-dev-forum...
>
> Have you localized the problem to the GetValue function?  The problem
could
> be in the UnpackValue code.  Are you allocating memory for the CharPtr in
> the program that calls GetValue?  These are just guesses, without more
code,
> I can't suggest much more.
>
> Regards,
>
> Steve
>
> -----Original Message-----
> From: Timothy Astle [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, April 13, 2000 10:08 AM
> To: Palm Developer Forum
> Subject: Re: Simple example needed
>
>
> This is something I tried so that I could just Get a value from the
database
> so that I could display it.
>
> theValue.BeginningValue is a floating point number.
> UniqueID is just the record's ID tag
>
> CharPtr GetValue(UInt UniqueID)
> {
>      tblValue theValue;
>
>      VoidHand valueHandle = DmGetRecord(gValueDB, UniqueID);
>      UnpackValue(&theValue, MemHandleLock(valueHandle));
>      MemHandleUnlock(valueHandle);
>
>      return ((CharPtr)&theValue.BeginningValue);
> }
>
> What I'm using to display the information is:
> SetFieldTextFromStr(NfoStartofValueValueField, GetValue(1));
>
> Where it takes the CharPtr and places it in the Field.
>
> It compiles, etc, but when I run it, I get a DataManager error.  My best
> guess is that it has to do with the way I'm attempting to get the value
from
> the database... I dunno.  I figure I'm probably going about this all the
> wrong way, but if someone could please help, I'd appreciate it.
>
> --
>
> Timothy Astle
>
>
>
>
>
>
>
>
> Timothy Astle <[EMAIL PROTECTED]> wrote in message
> news:8137@palm-dev-forum...
> >
> > I have 3 databases set up, and 6 structures (packed and unpacked
> versions).
> > I also have packing and unpacking funcitons set up.
> >
> > I was wondering if anyone had a "stripped down" piece of code that
allowed
> > me to simply ADD and DELETE records.
> >
> > Any small example would be great, because I could take it from there and
> > expand upon it.
> >
> > Sincerely,
> >
> > Timothy Astle
> >
> >
> >
> >
>
>
>
> --
> For information on using the Palm Developer Forums, or to unsubscribe,
> please see http://www.palm.com/devzone/mailinglists.html
>
>



-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palm.com/devzone/mailinglists.html

Reply via email to