[futurebasic] Re: [FB] Modem/OPEN "C"

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : September 2001 : Group Archive : Group : All Groups

From: ted spencer <ted@...>
Date: Tue, 18 Sep 2001 12:09:57 -0400
From the nimble fingers of Terrald J. Smith (terrald@...) (18/9/2001
8:08 AM) came...

> 
> clear local
> LOCAL FN WaitModemMsg$(PortID%, WaitTicks&)
> // Variables
> DIM Rcvd$,Tmp$,StopTime&,TheChar%
> // Read Modem Message
> StopTime& = WaitTicks& + FN TICKCOUNT
> DO
> READ #PortID%, Tmp$;0
This will read all the characters in the buffer  (up to 255) into Tmp$,
unless there's nothing there, in which case it passes on to better things.
Changing 0 to 1 will force it to sit there until there is a character to
read; if that character doesn't come, you're toasted.
> TheChar% = ASC(Tmp$) AND 127
Use the low half of the ASCII map - no accented characters or little apples
and such.
> SELECT CASE TheChar%
> CASE 0,10'Ignore Line feeds...
... and the 'nul' character which is a legitimate thing, too...
> CASE 13     : Rcvd$ = Rcvd$ + "<cr>"'Show Carriage returns...
> CASE < _" " : Rcvd$ = Rcvd$ + "<&"+RIGHT$(HEX$(TheChar%),2)+">"'Show Control
'space' is generally considered to be the lowest-numbered printable
character, and this catches all of them (except for <cr> which has already
been caught). The ones below that include carriage return and line feed
which are printable in a way, and other things which include characters for
Xon/Xoff handshaking.
> characters...
> CASE ELSE  : Rcvd$ = Rcvd$ + CHR$(TheChar%)'Add to returned string...
> END SELECT
> UNTIL TheChar% = 13 OR FN TICKCOUNT > StopTime&
...carriage return...
> END FN = Rcvd$

A little something like:

open "C",#tport,57600,_noparity,_onestopbit,_eightbits,2000
handshake #tport,_none

doesn't go amiss either: look under "Handshake" in the manual...
-- 
Ted Spencer; ted@...
-- 
A successful business man is one who, when he sees his competitor struggling
in the water, throws him a rock.
(Ray Kroc; founder of MacDonalds)