Other topics about Using Macro
This sample program demonstrates how to save the formatted data arrays in csv file (Result.csv)
Copy the following code into a Notepad file.
Save the file on the analyzer storage in the D: folder. Name the file as "readingData.vbs".
Double-click the file to execute.
On Error Resume Next
Dim ana
Dim Result
Dim Freq
Dim StrTemp
Dim objFSO
Dim objFile
Set ana = CreateObject("E4991.Application")
ana.parse ":CALC1:PAR1:SEL"
ana.parse ":INIT1:CONT OFF"
ana.parse ":ABOR"
NoOfPoint = ana.parse(":SENS1:SWE:POIN?")
StrTemp = ana.parse(":SENS1:FREQ:DATA?")
Freq = Split(StrTemp, ",")
StrTemp = ana.parse(":CALC1:DATA:FDAT?")
Result = Split(StrTemp, ",")
Set objFSO = WScript.CreateObject("Scripting.FileSystemObject")
If Err.Number = 0 Then
Set objFile = objFSO.OpenTextFile("Result.csv", 2, True)
If Err.Number = 0 Then
j = 0
For i = 1 To NoOfPoint
objFile.Writeline(Freq(i-1)&" , "&Result(j)&" , "&Result(j+1))
j = j + 2
Next
objFile.Close
Else
WScript.Echo "File Open Error: " & Err.Description
End If
Else
WScript.Echo "Error: " & Err.Description
End If
Set objFile = Nothing
Set objFSO = Nothing