As you can see from the GXSW DLL procedures, all functions have a parameter nStatus that is used to return a status indicating if an error occurs (<0). Ideally, you should check the return value after each call as shown here:
Gx6138Close(m_nHandle, 2, nStatus)
If nStatus<>0 then
! error do something.. like abort or MsgBox()
endif
Placing the return-value-checking code after each call in the test program makes the program very long and hard to read. Instead, you can call a single error-checking procedure, the CheckError driver procedure, to perform that test. Call CheckError with the nStatus parameter returned from the DLL procedure as an argument.
CheckError shows the following code:
if nStatus<0 then
m_lLastError=nStatus
GxSWGetErrorString(nStatus, sError, 256, nErrorStatus)
error nStatus, sError	! generate exception
endif
The function checks to see if nStatus contains an error code. If it does, it retrieves the description of the error and calls the ATEasy statement error. The error statement generates an ATEasy run-time error displaying the error message returned from the DLL..
Looking through the RELAY driver commands such as RELAY, Close, and more reveals that when the user uses the driver commands to program the board, an internal procedure is called. It performs the action such as Gx6138Close and then checks to see if an error occurs.