6100 BSC Programming Manual

BSC Example
?page "WRITE TO COMM-LINE PROCEDURE - WRITE^COMM"
!*********************************************************************
!
! Function: Write a message to the line, EOT the line and post
! a new read on the line.
!
! Called by : TERM^COMPLETE
!
!*********************************************************************
PROC WRITE^COMM(COUNT); INT COUNT;
BEGIN
INT ERROR;
string status = error;
s^cpline^buffer ':=' clip^write^req for 2;
reqid := (reqid '+' 1); !WRITE THE DATA
cpline^buffer.clip^req^hdr.reqid := reqid;
cpline^buffer.clip^req^hdr.txtout^len := count;
cpline^buffer.clip^req^hdr.txtin^len := 0;
cpline^write^count := count '+' clip^req^hdr^len;
CALL WRITEREAD (comm^file, cpline^buffer,cpline^write^count,
clip^rsp^hdr^len,cpline^cnt^recvd);
CALL AWAITIO(comm^file);
IF < THEN
BEGIN
CALL FILEINFO(comm^file,error);
CALL DEBUG; !********** add file level error handler
END
ELSE IF cpline^buffer.clip^rsp^hdr.status THEN ! *** always look at status
BEGIN
error := 0;
status [1] := cpline^buffer.clip^rsp^hdr.status; !DISPLAY ERRORS
CALL clip^status^handler(term^buff);
IF ERROR <> EOT^RECEIVED AND
ERROR <> EOT^ON^LINE^BID THEN
BEGIN !YOU MAY RETRY,
s^cpline^buffer ':=' clip^disconnect^req for 2; !BUT HERE WE
reqid := (reqid '+' 1); !DISCONNECT THE
cpline^buffer.clip^req^hdr.reqid := reqid; !LINE IF ERROR
cpline^buffer.clip^req^hdr.txtout^len := 0; !WAS OTHER THAN
cpline^buffer.clip^req^hdr.txtin^len := 0; ! "EOT".
CALL WRITEREAD (comm^file, cpline^buffer,clip^req^hdr^len,
clip^rsp^hdr^len,cpline^cnt^recvd);
CALL AWAITIO(comm^file);
IF < THEN
BEGIN
CALL FILEINFO(comm^file,error);
CALL DEBUG; ! ******** process file level error
END;
! ****** I don't care what status comes back after disconnect req
B-14