User`s manual

Typical Visual BASIC
Example Program
Using Agilent SICL
The following is an example program written in Visual BASIC using the
Agilent Standard Instrument Control Library. The program:
sends commands to the AFG to generate an arbitrary waveform;
receives data from the AFG;
shows how to send coupled commands;
and performs error checking of the AFG.
Only program codes are given here. Refer to the actual program on the CD
to see the data that generates the form, buttons, etc.
’ ARBWAVE.FRM - This program generates a 100 points ramp. The data to generate
the ramp is transferred to the AFG as comma separated voltages
’ Instrument GPIB address
Const ShowAddr = "hpib7,9,10"
Dim Addr As Integer
Dim ChkName As String
Sub CheckError (SubName As String)
’ Check for any errors
Dim Actual As Long
Dim RdErr As String * 256
Dim Work As String
Dim ErrNum As Integer
Dim TempName As String
TempName = ChkName
ChkName = "CheckError"
Read error message
Call iwrite(Addr, ByVal "SYSTem:ERRor?" + Chr$(10), 14, 1, Actual)
Call iread(Addr, ByVal RdErr, 256, 0, Actual)
If error was detected
ErrNum = Val(RdErr)
If ErrNum <> 0 Then
’ Store message only into Work string
Work = Mid$(RdErr, 1, Actual - 1)
Work = Work + " - in Sub " + SubName
’ Enable and clear error list box
ShowErr.Enabled = True
ShowErr.Visible = True
ShowErr.Clear
Continued on Next Page
Chapter 1 Getting Started 33