C H A P T E R 1 6 - C H A N G E L O G
AT5600 User Manual 98-119 issue 14 Page 417
In the code example shown above, it is worth noting the following points:
• vntResult(1 To 99) is declared as a variant type because the
GetVariantResult method can return either a numerical value
corresponding to a valid result, or a string corresponding to an error
message.
• The line
Set objServerResult = CreateObject("Server.Results")
creates the server.Results automation object within Visual Basic.
When trying to read the result with
Do
vntResult(nTest) = objServerResult.GetVariantResult(sComPort, nTest)
Loop Until (vntResult(nTest) <> "NO RESULT") And _
(vntResult(nTest) <> "INVALID RESULT NUMBER")
Two tests for ‘No Result’ and ‘Invalid Result Number’ are included.
The GetVariant method will normally read back ‘No Result’, until a measurement
has occurred. The next time it is executed after a new result has been sent to the
server, GetVariant will read back the actual result value. The act of doing this will
set a flag in the Server to say that the data has been read, so that any further
executions of the GetVariant statement before another result has been
transferred to the server will then return the ‘No Result’ reply.
Although the test number is fixed (= 3) in this example, the ‘Invalid Result
Number’ test is also included. This is because the GetVariant method can be
activated at exactly the same time as the results are being transferred from the
AT to the server. Depending on the speed and other parameters of your PC,
there may be a small time during the transfer when the result number requested
can be read as invalid. Including this test in the loop will trap out this error.
Instead of using the GetVariantResult function itself to determine if new data is
available, the NewDataAvailable function can be used. This function is
recommended for use when more than one item of data is to be read after new
data is available. For example, the NewDataAvailable function can be read in the
do loop until it returns true, after which any other OLE function can be called to
gather their return values knowing that all the data will be valid. Using the
NewDataAvailable function also means that checking for 'INVALID RESULT
NUMBER' and 'NO RESULT' return values is no longer necessary.