If you store a char * in a database as pointer, you'll have problems.
You instead need to store the character to which your char * points.
As soon as you free your string or exit your program, your pointer
becomes invalid -- by storing the actual characters instead, you
preserve your data.
Look in the archives for discussions of packing database records. In
general, you'll want a scheme where the DB record has some fixed
length data at the start, followed by a set of variable length
strings. Writing pack/unpack functions for your data types is a good
exercise.
On 4/16/06, Joel Henderson <[EMAIL PROTECTED]> wrote:
> I am using PODS to create a 68k application.
>
> I am storing a string from a TextBox into a character pointer. The reason I
> am storing it in a charcter pointer is because I need it to be of variable
> length and using a character pointer seems to be the best way to do this.
>
> When I write this data to a database and then export the database to a text
> file I get the correct number of characters, but the characters are not ASCII
> and not the text string I intended to save.
>
> If I use a character array it works fine except that the unused spaces have
> NULL characters in them which I don't want.
>
> When I step through the debugger in PODS the character pointer, when viewed
> as StringC shows the proper string, but when it's stored to the database it's
> stored using the character encoding. Any suggestions?
>
> Here's some relevant code:
>
> struct
> {
> char openFlag[3];
> char cardID[8];
> char separator2;
> char *EventType; //Using EventType[15] works but is not Variable
> char separator3;
> char myDate[7];
> char separator4;
> char myTime[8];
> char terminator;
> } Data;
> .
> .
> .
> char * pEventType;
>
> pField = FrmGetObjectPtr(pForm, FrmGetObjectIndex(pForm, ListID)); pEventType
> = FldGetTextPtr(pField);
>
> StrCopy(Data.EventType, pEventType);
>
>
> --
> 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/