Subj : Re: Win32 RS-232 help To : borland.public.cpp.borlandcpp From : Bob Gonder Date : Thu Apr 29 2004 12:47 pm Jeff Baker wrote: > if ((! ReadFile(Com.handle,Com.received,to_read,&read,NULL)) || (to_read >!= read)) Not knowing the Standard well, I don't like if( left || right ) where "right" depends on "left". Maybe the Standard guarantees it, but it looks messy. > { > if (to_read != read) cprintf("Received %d bytes from %s, we expected >%d (TIME_OUT)!\r\n",read,Com.number,to_read); > else cprintf("Unable to read from %s!\r\n",Com.number); > } > gotoxy(1,10); > cprintf("REC: "); > for(x = 0; x < to_read; x++) > { > cprintf("%X ",Com.received[x]); > clreol(); > } > } How about: BOOL bRF; gotoxy(1,10); cprintf("REC: "); clreol(); totalread = read = 0; do{ for(x = 0; x < read; x++) cprintf("%X ",Com.received[x]); bRF = ReadFile(Com.handle,Com.received,to_read,&read,NULL); totalread += read; to_read -= read; }while( bRF && (read != 0) ); if( !bRF ) read error; if( to_read != 0 ) short read error Needs a lot of work, but I think you can get the idea. For instance, you could change to this ReadFile(Com.handle,&Com.received[totalread],to_read,&read,NULL); and move the display to after the while. .