[comp.lang.pascal] How Can I empty COM1 port in TP?

cncst@unix.cis.pitt.edu (Christophe N. Christoff) (09/03/90)

The title says it all.  How can I empty COM1 port in TP?
How can I tell how many characters are there in COM1?

reeves@dvinci (Malcolm Reeves) (09/04/90)

From article <34499@unix.cis.pitt.edu>, by cncst@unix.cis.pitt.edu (Christophe N. Christoff):
> 
> The title says it all.  How can I empty COM1 port in TP?
> How can I tell how many characters are there in COM1?

Read them one at a time until there are none.
This isn't meant to be a facetious reply - to answer your question I need to
know how you are reading from COM1. You should have a buffer somewhere with
a pointer to tell you how full it is. I flush the COM buffer by setting the
pointer to position zero but there are lot's of ways to write a serial port
handler. There's a PD unit called Asynch I think which does a reasonable job.
Hope this is of some use.

ffritze@hpwad.HP.COM (#Fromut Fritze) (09/04/90)

> The title says it all. ....

I'm not sure - at least not to me

> How can I tell how many characters are there in COM1?

It's a serial port. Once you read one byte, another byte might appear form
your source. Unless you use any measn of handshake to stop the sender from
drowning you in bytes, you have to be fast in reading / processing. Depending
on your sender, any number of bytes may appear or get lost at COM1.

------------------------------------------------------------------------------
internet: ffritze@hpwadrd.hp.com
hpdesk:   Fromut FRITZE / HPB400 / R1
phone:    Germany 7243 602296
address:  Fromut FRITZE, Waldbronn Analytic Division R&D,
	  Hewlett Packard Str, D 7517 Waldbronn 2, Germany
------------------------------------------------------------------------------