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/

Reply via email to