6100 BSC Programming Manual

BSC Example
?PAGE "TERMINAL COMPLETION PROCEDURE - TERM^COMPLETE"
!*********************************************************************
!
! Function: This routine will write a message, entered on the terminal,
! to the line. STX & ETX must be added to the buffer.
! First, abort the outstanding read. If read aborted
! sucessfully, the write operation follows. otherwise,
! "TRANSMISSION ABORTED" is displayed on the screen.
! (note: You could queue the write until read completes)
!
! Called by : MAIN
!
! calling : WRITE^COMM, WRITE^TERM,COMM^COMPLETE
!
!*********************************************************************
PROC TERM^COMPLETE(TERM^READ^COUNT); INT TERM^READ^COUNT;
BEGIN
INT ERROR,count; STRING .SP,status = error;
s^cpline^buffer.clip^req^hdr.func ':=' clip^haltread^req for 2;
reqid := (reqid '+' 1); !WE GOT HERE
cpline^buffer.clip^req^hdr.reqid := reqid; !DUE TO A "CR"
cpline^buffer.clip^req^hdr.txtout^len := 0; !ON THE TERM,
cpline^buffer.clip^req^hdr.txtin^len := 0; !ABORT THE READ
CALL WRITEREAD (comm^file, cpline^buffer,clip^req^hdr^len, !SO WE CAN SEND
clip^rsp^hdr^len,cpline^cnt^recvd);
CALL AWAITIO(comm^file,,count); ! for the READ request
IF < THEN
BEGIN
CALL FILEINFO(comm^file,error);
CALL DEBUG; ! ******** process file level error
END
ELSE
IF cpline^buffer.clip^rsp^hdr.func = clip^read^req[0] THEN
BEGIN ! ******* read is done, save status and AWAITIO abort request
error := 0;
status [1] := cpline^buffer.clip^rsp^hdr.status;
CALL AWAITIO(comm^file,,count); ! for the ABORT request
END
ELSE
BEGIN ! ******* abort finished first, AWAITIO read request
CALL AWAITIO(comm^file,,count); ! for the READ request
error := 0;
status [1] := cpline^buffer.clip^rsp^hdr.status;
END;
IF error THEN ! let's check error for the read request
BEGIN
IF error = operation^timed^out THEN
BEGIN
s^cpline^text^buffer ':=' stx & s^term^buff !ALL IS WELL
B-16