6100 MPS-B Programming Manual

6100 MPS-B PROGRAMMING EXAMPLE
?PAGE "PROCEDURE: DO^MAIN"
PROC do^main MAIN;
BEGIN
LITERAL error = 1;
INT retry^count;
CALL initialize;
! Enable continuous
CALL request (poll,enable^continuous); ! polling.
DO ! infinite loop
BEGIN
retry^count := 0;
DO ! initiate polling
BEGIN
! Poll until a station responds with data or retry count is
! exhausted.
CALL request (readline,sequential^poll,,line^read^count);
IF status <> 0 THEN
BEGIN ! recovery
! A Status error indicates that no stations responded or a
! line error occurred. Let’s do recovery.
IF retry^count = max^retries THEN CALL error^exit;
retry^count := retry^count + 1;
!:
!:
!:
! After appropriate error recovery, let’s reset the line.
CALL request (control,reset);
status := error;
END;
END ! of poll.
UNTIL status = 0;
B-16