VB Script: Reading Data

Other topics about Sample Application Program

Overview

This sample program demonstrates how to save the formatted data arrays in csv file (Result.csv)

  1. Copy the following code into a Notepad file.
  2. Save the file on the analyzer storage in the D: folder. Name the file as "readingData.vbs".
  3. Double-click the file to execute.

Sample Program

On Error Resume Next

Dim ena

Dim Result

Dim Freq

Dim StrTemp

Dim objFSO     

Dim objFile

Set ena = CreateObject("E5070.Application")

ena.parse ":CALC1:PAR1:SEL"

ena.parse ":INIT1:CONT OFF"

ena.parse ":ABOR"

NoOfPoint = ena.parse(":SENS1:SWE:POIN?")

StrTemp = ena.parse(":SENS1:FREQ:DATA?")

Freq = Split(StrTemp, ",")

StrTemp = ena.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