Envoy Application Programming Manual

Table Of Contents
BISYNC Point-To-Point Protocol
Envoy Application Programming Manual427159-001
3-48
Line Bid
Example 3-18. Program Code for read^text and write^text (Page 4 of 5)
PROC example MAIN;
BEGIN
INT .buf[0:max^line-1], ! general purpose buffer.
count;
! read the start-up message to identify home terminal.
buf ':=' ["$RECEIVE", 8 * [" "]];
CALL OPEN (buf,count);
CALL READ (count,buf,66);
CALL CLOSE(count);
! open the home terminal.
CALL OPEN (buf[9], termfnum, 1); ! nowait.
IF < THEN CALL ABEND;
! open the line.
CALL OPEN (buf[21], linefnum );
IF < THEN CALL ABEND;
! issue a nowait WRITEREAD on the home terminal.
termbuf := "? ";
CALL WRITEREAD ( termfnum, termbuf, 1, 72 );
linestate := cntlstate;
WHILE 1 DO
BEGIN
IF NOT (lerror := read^text ( buf , count )) THEN
BEGIN ! read text.
CALL CANCEL ( termfnum );
CALL WRITE( termfnum, buf, count );
CALL AWAITIO ( termfnum );
IF < THEN CALL ABEND;
END
ELSE
IF lerror = eot^rcvd THEN
BEGIN
IF linestate = readstate THEN ! transmission
BEGIN ! complete.
! issue a nowait WRITEREAD on the home
! terminal.
termbuf := "? ";
CALL WRITEREAD ( termfnum, termbuf, 1, 72 );
END;
linestate := cntlstate;
END