SNAX/APC Management Programming Manual

Programming Example
B–4 111813 Tandem Computers Incorporated
BEGIN
! Handle errors in calls on SPI procedures.
END; ! of handle^spi^error
?PAGE "PROC: CALL^SCP"
! **************************************************************
! * call^scp *
! **************************************************************
INT PROC call^scp;
BEGIN
! This procedure sends a command to SCP and retrieves the
! response. The value returned by call^scp is the value of
! the return token in the response.
INT error, ! error code for WRITEREAD error
sserror, ! returned by call on SPI procedure
return^token, ! the value of the return token
init^buffer,
write^count,
read^count,
count^read;
sserror := SSGETTKN( buffer, zspi^tkn^usedlen, write^count );
IF sserror THEN
CALL handle^spi^error( sserror ); ! error on the call
read^count := zapc^val^buflen - 2;
CALL WRITEREAD( scp^file^num, buffer, write^count, read^count,
count^read );
IF <> THEN
BEGIN ! An error occurred during WRITEREAD.
CALL FILEINFO( scp^file^num, error ); ! get error code
CALL DEBUG;
END;
! Reinitialize the buffer length in the buffer.
buffer[1] := zapc^val^buflen - 2;
! Reinitialize the initial position in the buffer.
init^buffer := zspi^val^initial^buffer;
sserror := SSPUTTKN( buffer, zspi^tkn^initial^position,
init^buffer );
IF sserror THEN
CALL handle^spi^error( sserror ); ! error on the call
! Get the value of the return token.
sserror := SSGETTKN( buffer, zspi^tkn^retcode, return^token );
IF sserror THEN
CALL handle^spi^error( sserror ); ! error on the call
RETURN return^token;