Announcement

Collapse
No announcement yet.

Script Error

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

  • Guest
    Guest replied
    Originally posted by JimSpy View Post

    Hmmm. Processing. Analyzing. Absorbing.
    One thing to remember is that the VB .net script is compiled by the regular VB .net compiler, but Homeseer does things to the script before passing it to the compiler, so that the code will work in the Homeseer environment. One of those things is to supply the compiler with the Homeseer unique routines (or API), and those routines will have that "hs." prefix.

    So you do need to keep in mind that some things are unique to the Homeseer environment, and the rest is just standard VB .net.

    Leave a comment:


  • JimSpy
    replied
    Originally posted by aa6vh View Post
    MsgBox is a windows API call, not an HS call. (It may also exist in the linux world, don't know.) So it works in your script, but like said above, it would only display on the PC the HS Server is running on. "hs.MsgBox" does not exist.
    Hmmm. Processing. Analyzing. Absorbing.

    Leave a comment:


  • Guest
    Guest replied
    MsgBox is a windows API call, not an HS call. (It may also exist in the linux world, don't know.) So it works in your script, but like said above, it would only display on the PC the HS Server is running on. "hs.MsgBox" does not exist.

    Leave a comment:


  • JimSpy
    replied
    Originally posted by jon00 View Post

    That would be msgbox("Internet is down") not hs.msgbox

    I don't recommend using it as you have to be on the same PC as HS is running (Windows only BTW) and blocks the script from running any further if it is not acknowledged.
    Right. OK. Sure.

    But...But...But...why just msgbox, isn't that an HS-unique function? I mean, it has the ability to read in global variables, and present them in the msgbox, right? So it has to access the HS API? Isn't that the criteria for putting hs.* before a function?

    Leave a comment:


  • jon00
    replied
    Originally posted by JimSpy View Post

    Thanks, Jon, I will give this a shot.

    But, but, but...I have used MsgBox before, does it only work in immediate mode or something? Maybe that's where I remember using it...
    That would be msgbox("Internet is down") not hs.msgbox

    I don't recommend using it as you have to be on the same PC as HS is running (Windows only BTW) and blocks the script from running any further if it is not acknowledged.

    Leave a comment:


  • JimSpy
    replied
    Originally posted by jon00 View Post
    Not sure where you got that from. Of course spaces are allowed!



    You are trying to run a VB Script (using the .txt extension) when the script contains VB.NET scripting components (such as Dim strName As String). hs.Msgbox does not also exist as a Homeseer scripting command.

    Try the following using a .vb extension (such as internetcheck.vb)

    Code:
    Sub Main(ByVal parms As String)
    
    Dim strName As String
    Dim intR As Integer
    
    strName = "8.8.8.8"
    intR = hs.ping(strName)
    
    If intR = 0 Then
    hs.WriteLog("Internet", "OK")
    Else
    hs.WriteLogEx("Internet", "?? ", "#49595")
    hs.Speak("Warning: Internet is Down. Repeat, Internet is Down", True)
    End If
    
    End Sub
    Thanks, Jon, I will give this a shot.

    But, but, but...I have used MsgBox before, does it only work in immediate mode or something? Maybe that's where I remember using it...

    Leave a comment:


  • JimSpy
    replied
    Originally posted by Stuart View Post
    I also run something similar to this but in addition if the internet is down it also reboots my router and wireless, which can sometimes be a problem. It runs once an hour and is great to fix problems and you do not have to be home.

    Stuart
    It's almost never our router (Gryphon) or our modem (Arris), it's our alleged provider, SuddenStink. If a squirrel isn't chewing on our T1, a wildfire is melting some fiber optic cable. Or they just decide to give their servers a rest or something. This is why I have the thing run every 5 minutes, so I can get right on the phone and bitch them out.

    Leave a comment:


  • JimSpy
    replied
    Originally posted by George View Post
    Can't have blank lines, all blank lines have to start with a accent mark ' to be a comment. It can be a blank comment but no really blank lines.
    Either remove the blank lines or put a ' in the 1st column
    First I've heard that. But maybe they've changed the rules....

    Leave a comment:


  • Guest
    Guest replied
    Originally posted by jon00 View Post
    You are trying to run a VB Script (using the .txt extension) when the script contains VB.NET scripting components (such as Dim strName As String). hs.Msgbox does not also exist as a Homeseer scripting command.
    I missed that the script file had the incorrect extension, and the msgbox call. Oops.

    BTW - I prefer to use "object" rather than "string" for the input parameter declare. That way I can call the same script from HS Touch, which passes parameters as a string array instead of a single string. An object can take both, so handles a call from either side without getting a parameter mismatch error. If I am processing the input parameter(s), I just check to see what type parms is, and handle accordingly within the script.

    Leave a comment:


  • jon00
    replied
    Originally posted by George View Post
    Can't have blank lines, all blank lines have to start with a accent mark ' to be a comment. It can be a blank comment but no really blank lines.
    Either remove the blank lines or put a ' in the 1st column
    Not sure where you got that from. Of course spaces are allowed!

    Originally posted by JimSpy View Post
    Hey guys,

    Can anyone help me out with a simple fix? I copied a script from somewhere in this forum, and made it part of an event, but when the event runs I get an error.

    Here is the script:

    Sub Main()

    Dim strName As String
    Dim intR As Integer
    strName = "8.8.8.8"

    intR = hs.Ping(strName)

    If intR = 0 Then
    hs.WriteLog ("Internet", "OK")
    Else
    hs.WriteLogEx ("Internet", "?? ","#49595")
    hs.msgbox "Internet is down"
    hs.Speak ("Warning: Internet is Down. Repeat, Internet is Down", TRUE)

    End If

    End Sub


    ...and here is the error:

    Running script, script run or compile error in file: C:/Program Files (x86)/HomeSeer HS3/scripts/InternetDown.txt1025:Expected end of statement in line 3 More info: Expected end of statement

    There was a time when I could have figured this out myself, but I'm so confused between all the scripting languages. Does it have something to do with the file extension, *.txt, and it's not expecting *.vbs parameters or something?
    You are trying to run a VB Script (using the .txt extension) when the script contains VB.NET scripting components (such as Dim strName As String). hs.Msgbox does not also exist as a Homeseer scripting command.

    Try the following using a .vb extension (such as internetcheck.vb)

    Code:
    Sub Main(ByVal parms As String)
    
    Dim strName As String
    Dim intR As Integer
    
    strName = "8.8.8.8"
    intR = hs.ping(strName)
    
    If intR = 0 Then
        hs.WriteLog("Internet", "OK")
    Else
        hs.WriteLogEx("Internet", "?? ", "#49595")
        hs.Speak("Warning: Internet is Down. Repeat, Internet is Down", True)
    End If
    
    End Sub

    Leave a comment:


  • Guest
    Guest replied
    You do need to make your subroutine's declare statement match what HS is expecting. Try this:

    Code:
    Sub Main(parms As Object)
    You do not need to do anything else with parms, unless you want to process some input parameters.

    Leave a comment:


  • Stuart
    replied
    I also run something similar to this but in addition if the internet is down it also reboots my router and wireless, which can sometimes be a problem. It runs once an hour and is great to fix problems and you do not have to be home.

    Stuart

    Leave a comment:


  • George
    replied
    Can't have blank lines, all blank lines have to start with a accent mark ' to be a comment. It can be a blank comment but no really blank lines.
    Either remove the blank lines or put a ' in the 1st column

    Leave a comment:


  • JimSpy
    started a topic Script Error

    Script Error

    Hey guys,

    Can anyone help me out with a simple fix? I copied a script from somewhere in this forum, and made it part of an event, but when the event runs I get an error.

    Here is the script:

    Sub Main()

    Dim strName As String
    Dim intR As Integer
    strName = "8.8.8.8"

    intR = hs.Ping(strName)

    If intR = 0 Then
    hs.WriteLog ("Internet", "OK")
    Else
    hs.WriteLogEx ("Internet", "?? ","#49595")
    hs.msgbox "Internet is down"
    hs.Speak ("Warning: Internet is Down. Repeat, Internet is Down", TRUE)

    End If

    End Sub


    ...and here is the error:

    Running script, script run or compile error in file: C:/Program Files (x86)/HomeSeer HS3/scripts/InternetDown.txt1025:Expected end of statement in line 3 More info: Expected end of statement

    There was a time when I could have figured this out myself, but I'm so confused between all the scripting languages. Does it have something to do with the file extension, *.txt, and it's not expecting *.vbs parameters or something?
Working...
X