PORTREADCHAR

Synopsis
PORTREADCHAR
Description

Reads one byte from the currently open port and outputs it as an integer from -128 to 127. It also outputs "-1" if no character is available. Therefore, if PORTREADCHAR outputs -1, it could be there was no character available or that it successfuly read the -1 byte. For this reason, if -1 is a possible byte in the data your program expects, then it's better to use PORTREADARRAY.

Example
PORTOPEN "com1
SHOW PORTWRITECHAR ASCII "a
1
SHOW PORTWRITECHAR ASCII "t
1
SHOW PORTWRITECHAR 13
1
WAIT 60
PRINT "Reading...
Reading...
REPEAT 10 [MAKE "x PORTREADCHAR IF NOT :x = -1 [TYPE CHAR :x]]
PRINT ".
at||
OK|
.
PORTCLOSE

SourceForge.net Logo