hexagon logo

Writing/Reading a .txt file

This is very much a VB question not related to PC-DMIS. There is so much information out there for VB that I find it very hard to locate a good example of what I want to do.

I have a script at the beginning and end of my part program. I would like to get the total runtime of the program. I have a way to get systemtime in each and put it into seconds and such, thanks to this message board.

I do not want to write the beginning time to a variable and have it go through the part program. What I wanted was a temporary .txt file or something similar that I could write the begintime value (in seconds) to. The second script would grab this value and use it. The .txt file either needs to be cleared or overwritten by the new begintime number every execution. How do I code this?

My goal is to take these values and use them to calculate CMM run time for the day in Excel. Can I export the Total Runtime number I get in the second script to Excel? It will probably be easier to google information for this; I will update this post if I find what I am looking for.

Thanks!
Parents
  • I use this script to track how many time the CMM is used

    Sub Main()
    Dim AssetNumber As String
    Dim AssetLocation As String
    Dim PCDiLocation As String

    Dim StartDate As String
    Dim StartTime As String

    StartDate = Format(Date, "Short Date")
    StartTime = Format(Time, "Short Time")

    Open "c:\temp\CMMInit.txt" For Input As #1
    ' Where PC-DMIS The CMM Plant floor
    ' is installed Asset # CMM Location
    Input #1, PCDiLocation, AssetNumber, AssetLocation
    Close #1

    Open "c:\CMMAvail.txt" For Append As #1
    Print #1, AssetNumber & "," & AssetLocation & ",1," & StartDate & "," & StartTime
    Close #1

    End Sub

    I keep data about the CMM in a text file located in the "c:\temp" folder, the file name is CMMInit.txt. The data is comma separated and looks like this.

    C:\Program Files\WAI\PC-DMIS V42 MR1,OFFLINE,CM

    The first column is the installation location of PC-DMIS. The next column is the asset or serial number of the CMM. The last column is the location of the CMM on the shop floor.

    Hope this gets you started.
Reply
  • I use this script to track how many time the CMM is used

    Sub Main()
    Dim AssetNumber As String
    Dim AssetLocation As String
    Dim PCDiLocation As String

    Dim StartDate As String
    Dim StartTime As String

    StartDate = Format(Date, "Short Date")
    StartTime = Format(Time, "Short Time")

    Open "c:\temp\CMMInit.txt" For Input As #1
    ' Where PC-DMIS The CMM Plant floor
    ' is installed Asset # CMM Location
    Input #1, PCDiLocation, AssetNumber, AssetLocation
    Close #1

    Open "c:\CMMAvail.txt" For Append As #1
    Print #1, AssetNumber & "," & AssetLocation & ",1," & StartDate & "," & StartTime
    Close #1

    End Sub

    I keep data about the CMM in a text file located in the "c:\temp" folder, the file name is CMMInit.txt. The data is comma separated and looks like this.

    C:\Program Files\WAI\PC-DMIS V42 MR1,OFFLINE,CM

    The first column is the installation location of PC-DMIS. The next column is the asset or serial number of the CMM. The last column is the location of the CMM on the shop floor.

    Hope this gets you started.
Children
No Data