Announcement

Collapse
No announcement yet.

save timer value to text file

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    save timer value to text file

    I'm wanting to save the value of a timer to a simple .txt file (add to the bottom). How can I do this using a script?

    Thanks for reading and all all help is appreciated.

    #2
    My.Computer.FileSystem.WriteAllText("D:\clipboard.txt", p3 & ControlChars.CrLf, False, System.Text.Encoding.Unicode)

    This one write a value 'p3' to the mentioned file.
    False means, the value will be overwritten every time. Change it to True, it you want to have the new value every time on a new line.

    Comment


      #3
      Originally posted by ybanerd View Post
      I'm wanting to save the value of a timer to a simple .txt file (add to the bottom). How can I do this using a script?
      Running a script something like this from an event should do it. (It assumes the file already exists and just adds a new line at the end.)

      Code:
          Public Sub Main(ByVal Parms As Object)
      
              Dim strFileName As String = "simple.txt"
              Dim strData As String = hs.DeviceString(nnnn)    'where nnnn is the Ref ID of the timer device
      
              Dim fApnd As Object
              Dim oFS As Object
              Dim ForAppending As Integer = 8
      
              oFS = CreateObject("Scripting.FileSystemObject")
      
              fApnd = oFS.OpenTextFile(strFileName, ForAppending)
              fApnd.WriteLine(strData)                ' add data
              fApnd.close()                    ' Close the file 
      
              fApnd = Nothing
              oFS = Nothing
      
          End Sub
      Mike____________________________________________________________ __________________
      HS3 Pro Edition 3.0.0.548, NUC i3

      HW: Stargate | NX8e | CAV6.6 | Squeezebox | PCS | WGL 800RF | RFXCOM | Vantage Pro | Green-Eye | Edgeport/8 | Way2Call | Ecobee3 | EtherRain | Ubiquiti

      Comment


        #4

        THANKS A LOT

        BOTH ways will come in handy

        Comment

        Working...
        X