That's what I get for not just copying the hole thing and trying to do it
one line at a time, I was trying to only copy what was revenant, but it is
Char buffer[81] in the code. Anyway I tried skipping the hole buffer thing
and tried to copy a string into ptext like this
ptext=MemHandleLock(htext);
StrCopy(ptext,"This is a test");
MemHandleUnlock(htext);
FrmDrawForm(frm);
and I still only get the 5 charactors to dislplay, no mater what string I
try to load into it. I don't know what is going on.
Any Ideas?
I just noticed your slightly bizarre declaration section:
> > MemHandle htext;
> > FieldPtr fld;
> > FormPrt frm;
> > char* ptext;
> > buffer[81]
Don't you mean "Char buffer[81];"? I'd expect the compiler to complain
about that.
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]]On
Behalf Of Brad
> Jenkins
> Sent: Wednesday, February 07, 2001 1:58 PM
> To: Palm Developer Forum
> Subject: RE: Displaying Text in a Field
>
>
> Here is the code that I am using to load the buffer
>
> // I check to see if there is anything in the port buffer
> err=SrmReceiveCheck(commport, &bytecount);
> if(bytecount>0)
> {
> SrmReceive(commport, buffer, bytecount, TIMEOUT, &err);
> buffer[bytecount]=0; // terminate the end of the string
> ptext=MemHandleLock(htext);
> StrCopy(ptext,buffer);
> MemHandleUnlock(htext);
> FrmDrawForm(frm);
> }
>
> In debug, I can see that the string is being loaded into buffer.
> If I send
> "test123", I can see "test123" loaded into buffer and when copied ptext is
> pointing to the same string, but no matter what the length is it only
> displays 5 characters on the screen so only "test1" is displayed. I have
> tired commenting out buffer[byetcount]=0 and that makes no
> difference other
> than when it is in and fewer that 5 characters are sent you see a square
> character after the last character.
>
> > From: Brad Jenkins
> >
> > If I
> > send less than 5 characters it will still display 5, the last
> ones will be
> > what ever was last in the buffer. Here is a sample of the code
> that I am
> > using
> >
> > MemHandle htext;
> > FieldPtr fld;
> > FormPrt frm;
> > char* ptext;
> > buffer[81]
> >
> > htext = MemHandleNew(81);
> > frm = FrmGetActiveForm();
> > fld = (FieldPtr)FrmGetObjectPtr (frm, FrmGetObjectIndex(frm, MyField));
> > FldSetTextHandle(fld, htext);
> >
> > // charactors are loaded form port into buffer
> >
> > ptext=MemHandleLock(htext);
> > StrCopy(ptext,buffer);
> > MemHandleUnlock(htext);
> > FrmDrawForm(frm);
> >
> > // on exit from the program
> > MemHandleFree(htext);
> >
>
> You don't show the code for loading chars into the buffer. StrCopy(ptext,
> buffer) will copy chars from the address pointed to by buffer to
> the address
> pointed to by ptext stopping after it finds a '\0'. So it sounds like you
> have 5 chars plus '\0' in the buffer.
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/