Tony Janke wrote:
I get this error "field.c, Line:6001, FldSetText - text longer than
maxChars" ONLY when trying to read a number larger than 255 (8-bit). The variable I store the data in is 16 bit Int (data).

is this function supposed to be reading from the field or writing to it? your question suggests reading, but the code suggests writing.



the error occurs on line:       FldSetTextHandle(FieldPtr, h);

Code:
///////////////////////////////////////////////////////////////////////////////////////////////////////////
               UInt16                                      data,
controlID;
        FormType*               pForm;
        FieldType*              FieldPtr;
don't use FieldPtr as a variable name. this is usually typedefed as FieldType*.

        MemHandle               h, oldHandle;
        char*                   p;

        pForm = FrmGetActiveForm();
        h = MemHandleNew(50);           // allocate chunk of memory in

this is weird. just allocate it to the size you need. 6 is large enough for a UInt16.


heap
p = MemHandleLock(h); // prevent the chunk from moving
(lock) // and obtain pointer to location
StrIToA(p, data);
MemHandleResize(h, StrLen(p)+1);
MemHandleUnlock(h);
FieldPtr = FrmGetObjectPtr(pForm, FrmGetObjectIndex(pForm,
controlID));
oldHandle = FldGetTextHandle(FieldPtr);
FldSetTextHandle(FieldPtr, h);
FldRecalculateField(FieldPtr, true); // refresh the field
if(oldHandle)
MemHandleFree(oldHandle);

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

Reply via email to