Hi,
I suspect you should be using StrLen(text)+1 which gives the number of
characters in the text string (pointed at by text) plus 1 for the null
terminator.
The sizeof operator gives the size in bytes of the object you give it. In
this case you have asked for the sizeof a pointer (&text) which is 4 in
PalmOS.
Regards,
On 30/11/06, lulu <[EMAIL PROTECTED]> wrote:
>
> Hi
>
> thanks so much. It works now. I can write to a database and retrieve the
> data when I load the application again. The problem now is that I only
> retrieve the first four characters. It does not matter if I write 5 or 10
> characters, it only retrieves four.
>
> static void AppStop(void)
> {
> FormType* pForm;
> MemHandle RecHandle;
> MemPtr RecPointer;
> FieldType* field_text;
> Char *text;
> FieldType* field_text;
> Err error;
>
> pForm = FrmGetActiveForm();
>
> field_text = FrmGetObjectPtr(pForm, FrmGetObjectIndex(pForm,
> MainNameField));
> text=FldGetTextPtr(text_field);
> RecHandle=DmNewRecord(ntDB, &index, sizeof(&text)+1);
> RecPointer = MemHandleLock(RecHandle);
> DmWrite(RecPointer, 0, text, sizeof(&text)+1);
> MemHandleUnlock(RecHandle);
> DmReleaseRecord(ntDB, index, true);
> DmCloseDatabase(ntDB);
> FrmCloseAllForms();
> }
>
> And this is my code when I start the App
>
> static Err AppStart(void)
> {
> MemHandle RecHandle;
> MemPtr RecPointer;
> Char *s;
> Err error;
>
> ntDB = DmOpenDatabaseByTypeCreator(DBType, CreatorID, dmModeReadWrite);
> if (!ntDB)
> {
> error=DmCreateDatabase(0, DBName, CreatorID, DBType, false);
> if(error==0)
> ntDB = DmOpenDatabaseByTypeCreator(DBType, CreatorID, dmModeReadWrite);
>
> RecHandle=DmQueryRecord(ntDB, index);
>
> RecPointer = MemHandleLock(RecHandle);
> MemHandleUnlock(RecHandle);
>
> FrmGotoForm(MainForm);
> return errNone;
> }
>
> --
> 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/