Announcement

Collapse
No announcement yet.

Scripting help please - Run Time errors, Invalid Character at line x

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

    Scripting help please - Run Time errors, Invalid Character at line x

    Hello,

    I am hoping someone can help me, and stop me going mad!












    I can find no way to do this with normal events, so assume it needs to be a script? Any help would be greatly appreciated.

    Philip

    Example of a Test I was doing:

    Sub Main()
    Dim DevRef
    DevRef = hs.GetDeviceRefByName("Hall Lamp")
    if hs.ison(DevRef) then
    hs.writelog("test", "Weather Test Script")
    End If
    End Sub


    This then errors with "Invalid character in line 2". Urghhhh!

    #2
    Hi Philip;

    PHP Code:
    Sub Main(byVal parms as Object)
        
    Dim DevRef As Integer
        DevRef 
    hs.GetDeviceRefByName("Hall Lamp")
        if 
    hs.ison(DevRefthen
            hs
    .writelog("test""Weather Test Script")
        else
            
    hs.writelog("test","Light is off")
        
    End If
    End Sub 
    Hope this helps a bit....
    Don

    Comment


      #3
      Is your file suffix .vb ?

      tenholde


      Originally posted by vaugrat View Post
      Hello,

      I am hoping someone can help me, and stop me going mad!












      I can find no way to do this with normal events, so assume it needs to be a script? Any help would be greatly appreciated.

      Philip

      Example of a Test I was doing:

      Sub Main()
      Dim DevRef
      DevRef = hs.GetDeviceRefByName("Hall Lamp")
      if hs.ison(DevRef) then
      hs.writelog("test", "Weather Test Script")
      End If
      End Sub


      This then errors with "Invalid character in line 2". Urghhhh!
      tenholde

      Comment


        #4
        The extension of the file is .txt (although I did try with .vb).....and that threw up a whole host of other errors!

        Comment


          #5
          The example I suggested works for me. Sorry I couldn't be more help. :-(
          Don

          Comment


            #6
            This works for me as a vbscript file (.txt):

            Code:
            Sub Main()
            Dim DevRef
            DevRef = hs.GetDeviceRefByName("Ensuite Lights")
            if hs.ison(DevRef) then
            hs.writelog "test", "123"
            End If
            End Sub
            You were mixing vbscript and vb.net syntax. I would stick with vb.net and use the example that Don provided.

            Cheers
            Al
            HS 4.2.8.0: 2134 Devices 1252 Events
            Z-Wave 3.0.10.0: 133 Nodes on one Z-Net

            Comment


              #7
              Originally posted by donstephens View Post
              Hi Philip;

              PHP Code:
              Sub Main(byVal parms as Object)
                  
              Dim DevRef As Integer
                  DevRef 
              hs.GetDeviceRefByName("Hall Lamp")
                  if 
              hs.ison(DevRefthen
                      hs
              .writelog("test""Weather Test Script")
                  else
                      
              hs.writelog("test","Light is off")
                  
              End If
              End Sub 
              Hope this helps a bit....
              Thanks Don. I have got your sample to work without error...so I will have a go at recrafting and see if I can modify it to do what I am trying to achieve!

              Comment


                #8
                Great. Please feel free to post if you encounter problems.
                Don

                Comment

                Working...
                X