' === Wait for sweep complete ===
Do
SendLan ":stat:oper:even?" ' get Operation Event
Register
ReceiveLan strData
intData = Val(strData)
Loop While ((intData And 1) <> 1) ' Bit0: Sweep status
' === Analysis ===
SendLan ":calc:category swth" ' Spectrum width
analysis(THRESH type)
SendLan ":calc" ' Analysis Execute
SendLan ":calc:data?" ' get data
ReceiveLan strData
' === Capture analytical results ===
dblMeanWL = Val(Left(strData, 16)) ' get mean wavelegnth
dblSpecWd = Val(Mid(strData, 18, 16)) ' get spectrum width
' === Output the result to the screen ===
MsgBox ("MEAN WL: " & dblMeanWL * 1000000000# & " nm" & vbCrLf & _
"SPEC WD: " & dblSpecWd * 1000000000# & " nm")
' === Disconnect ===
Winsock1.Close
'Wait to disconnect complete
While (Winsock1.State <> sckClosed)
DoEvents
Wend
End Sub
'==================================================
' Sub routine
' Send Remote Command
'==================================================
Sub SendLan(strData As String)
Winsock1.SendData strData & vbCrLf
DoEvents
End Sub
'==================================================
' Sub routine
' Receive query data
'==================================================
Sub ReceiveLan(strData As String)
Dim strData2 As String
strData = ""
Do
Winsock1.GetData strData2, vbString
strData = strData + strData2
DoEvents
Loop While (Right(strData, 1) <> vbLf)
End Sub
3.3 Sample Program