Skip to main content

VBScript Error Handling -- different from VBA

    'On Error GoTo ErrHandler

    ' TODO: Add your code here

    ' final code
    
    OnErrorResumeNext

    Dim FolderName

    FolderName = "M100x"

    Dim FolderName1

    FolderName1 = Trim(FolderName)

   

    'ENSURE THAT FOLDER NAME CORRESPONDING TO WINDING SR NO IS CREATED AND CONTAINS THE FILE MeasLog.csv

    'ENSURE THAT THE SAME WINDING SR NO IS ENTERED IN THE HMI FIELD D4502

   

   

    Dim outputString

    Dim outputFile

    Dim inputFile

    Const ForWriting = 2

    Const ForReading = 1

    Set objFSO = CreateObject("Scripting.FileSystemObject")

    Set outputFile = objFSO.CreateTextFile("F:\csv\" + "Logger.csv", ForWriting, True)

    outputFile.WriteLine FolderName1

    Set inputFile = objFSO.OpenTextFile("F:\csv\" + FolderName1 + "\MeasLog.csv", ForReading)
    
    If Err.Number <> 0Then
    MsgBox"Error No:" & Err.Number & " - " & _
          Err.Description & " has occurred"
    Err.Clear
    Else
          Alert z
    EndIf

   

    Dim temp

    temp = inputFile.ReadLine' read the 1st line and discard

    outputFile.WriteLine temp





    'Dim temp1()

    'temp1 = Split(inputFile.ReadLine, ",")

    'outputString = Join(temp1, ",")

    'outputFile.WriteLine outputString




    
   



    outputString = inputFile.ReadLine

    outputFile.WriteLine outputString

           
    outputString = inputFile.ReadLine

    outputFile.WriteLine outputString


    outputString = inputFile.ReadLine

    outputFile.WriteLine outputString

           
    outputString = inputFile.ReadLine

    outputFile.WriteLine outputString

           
    outputString = inputFile.ReadLine

    outputFile.WriteLine outputString


    outputString = inputFile.ReadLine

    outputFile.WriteLine outputString


    outputFile.Close

    inputFile.Close

Comments

Popular posts from this blog

GXWorks3 GXDeveloper3 Notes

Set Device comment using Navigation Tree View -> Device-> Common Device Comment Q1. Blinking erratic display of values when choosing Controller Type : FX A1. Communication issue between the GS2110 HMI and the FX5U PLC over ethernet was resolved by the following settings : System Tree View -> Controller Setting ->CH1-> Controller Type : Melsec iQ-F , I/F : Ethernet Multi Unit type : FX5CPU, IP Address : 192.168.1.17, Port : 5562, Communication TCP Q2. When communication between the FX5U PLC and the GS2110 HMI was established the GXWorks3 Programming software was unable to go online with the PLC - gives communication error A2. The PLC connection set to "Direct" and not "Via Hub" Q3  Unable to establish simultaneous communication to FX5U PLC with SCADA (MX OPC Server ) and HMI ( GS2110 ) Need to add Melsoft  device to correspond to the HMI as shown below Q4. Functions and Function Blocks Functions :  1. Do not get i...

FX5U PLC Module Settings

FX5U-4AD-PT-ADP FX5U-8AD