Announcement

Collapse
No announcement yet.

Scripting and writing to file

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Scripting and writing to file

    I'm trying to write the following to a text file {"state":"closed"}
    This is the script I'm using




    sub main(sVal)
    Dim fso,f1
    Const OpenFileForReading = 1
    Const OpenFileForWriting = 2



    Path = "html/garagedoorstatus.html"
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set file = fso.OpenTextFile(path, 2,True)


    file.WriteLine (" {"state":"closed"} ")


    file.Close
    end sub



    but when I run it I get an error......
    Running script, script run or compile error in file: GARAGEDOORCLOSED1006:Expected ')' in line 13 More info: Expected ')'

    Seems like it doesn't like the quotes on either side of the state and closed?
    When I take those out it runs just fine, should there be something else in there because of the extra quotes?

    #2
    Try

    Code:
    file.WriteLine (" {""state"":""closed""} ")
    HS 4.2.8.0: 2134 Devices 1252 Events
    Z-Wave 3.0.10.0: 133 Nodes on one Z-Net

    Comment


      #3
      Originally posted by sparkman View Post
      Try



      Code:
      file.WriteLine (" {""state"":""closed""} ")


      Thanks!
      I've been trying to figure that for a while now.


      Sent from my iPhone using Tapatalk

      Comment


        #4
        Dear Sparkman, Tommy,

        i'm juts started in "scripting", and I exactly want to do what you just mentionned above.

        My issue is when i copy and paste the above code with the modification i get a log error :

        Running script, script run or compile error in file: C:/Program Files (x86)/HomeSeer HS3/scripts/test3.txt0: in line 0 More info: Exception de HRESULT : 0x800A01C2

        It's rough french but basically ... in line 0 ( what is line 0 ???) i have a Hresult expection ....

        would you have any clue to help me progress ?

        Many thanks !
        Phil

        Comment


          #5
          Try this VB.NET script (save with the extension.vb)

          PHP Code:
          Imports System.IO

          Sub Main
          (ByVal Parm As Object)

              
          Dim FileWriter As StreamWriter
              Dim Path 
          As String ""

              
          Path "C:\mMyfile.txt"

              
          FileWriter = New StreamWriter(Path)
              
          FileWriter.writeline  ("{""state"":""closed""}")
              
          FileWriter.close

          End Sub 
          Jon

          Comment


            #6
            Many thanks Jan00.

            Works fine. i can start building on this ... More to come i guess

            thanks again for your support

            Comment

            Working...
            X