Announcement

Collapse
No announcement yet.

Object reference not set to an instance of an object with hs.GETUrl VB Script

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

    Object reference not set to an instance of an object with hs.GETUrl VB Script

    I am running the following script and I get the following error. Any thoughts?

    Sub main()
    Dim startint
    Dim Endint
    Dim Strdata as string


    Strdata = hs.GetURL("http://lite.cnn.io", "/en" , true, 80)

    End Sub

    VB.Net script exception(0), re-starting: Object reference not set to an instance of an object

    #2
    Your startint and Endint variables are null. Initialise the variable as an integer and assign a value. Or just remove them from your dimension section of code

    Comment


      #3
      Thanks for replying, doesn't appaer to be the issue I removed the variables and still get the error

      Comment


        #4
        Change your script to:

        Code:
        Sub Main(parms As Object)
          Dim Strdata As String
          Strdata = hs.GetURL("http://lite.cnn.io", "/en" , true, 80)
        End Sub
        HS tries to pass a input parameter to Main, but your Main did not allow it.

        Comment


          #5
          Thank you I. actually tried that and I get the same error.

          Comment


            #6
            Originally posted by wkrasner View Post
            Thank you I. actually tried that and I get the same error.
            Well, your script will fail without that declare.

            How are you evoking this script? Will the script work if you replace the GetUrl call with:
            Code:
            hs.WriteLog("Testing", "Testing")
            The script error processing can be a little obtuse sometimes. Can we see the entire error message (which should be in the system log, where you should see the Testing message as well)?

            Comment


              #7
              VB.Net script exception(0), re-starting: Object reference not set to an instance of an object.

              Yes same error with just writelog

              Comment


                #8
                Are you by chance calling the script from an event? If so when it asks for sub to call are you using Main? If so I would remove the main. I have had problems with this before.

                Comment


                  #9
                  That throws a namespace error:
                  Compiling script C:\Program Files (x86)\HomeSeer HS3\scripts\getnews.vb: Identifier expected.
                  Dec-31 13:10:07 Error Compiling script C:\Program Files (x86)\HomeSeer HS3\scripts\getnews.vb: Namespace or type specified in the Imports 'System.Core' doesn't contain any public member or cannot be found. Make sure the namespace or the type is defined and contains at least one public member. Make sure the imported element name doesn't use any aliases.

                  Comment


                    #10
                    Can you post your whole script with the forums script tags around it?
                    HS 3.0.0.548: 1990 Devices 1172 Events
                    Z-Wave 3.0.1.262: 126 Nodes on one Z-Net

                    Comment


                      #11
                      Code:
                      Sub (parm as object)
                      
                      Dim Strdata as string
                      Strdata = hs.GetURL("http://lite.cnn.io", "/en" , true, 80)
                      hs.writelog ("test", "test")
                      End Sub

                      Comment


                        #12
                        You are missing main after the sub. I was talking about the call from event to remove the main.

                        Comment


                          #13
                          This is how it looks in an event

                          Click image for larger version  Name:	Screenshot from 2019-12-31 13-18-45.png Views:	0 Size:	59.3 KB ID:	1350865

                          here is the data from my log - Notice i changed for "test" to StrData

                          CNN - Breaking News, Latest News and VideosCNN | 12/31/2019 | ListenMain StoriesAll the cadets pictured giving a Nazi salute will be fired, West Virginia governor saysOpinion: Anti-Semitic attacks show a society at risk of falling apartThe suspect in the NY Hanukkah stabbings now faces federal hate crime charges. Here's what authorities foundReligion is widening the partisan divideProtesters attack US embassy in Baghdad after airstrikesUS flies Apache helicopters over protesters at US embassy in IraqTrump spent 1 of every 5 days at one of his golf clubs in 2019Australian wildfires force thousands to flee to beachPuffins scratched their itches with sticks. It's the first evidence seabirds use toolsJudge dismisses impeachment witness lawsuit after House rescinds subpoenaLawyer for indicted Giuliani associate asks court's permission to share material with House investigatorsNYT: White House predicted congressional pushback for holding Ukraine aidOpinion: The case for letting senators vote secretly on Trump's fateEx-Nissan chief Carlos Ghosn has fled Japan for Lebanon8 extraordinary video moments from 2019Anderson Cooper Full CircleQuickly catch up on the day's newsFollow the New Year around the world A cop said McDonald's workers wrote a derogatory term on his cup. He made it up, police chief saysTrump signs robo-call bill into lawSyd Mead, the visual artist behind 'Blade Runner' dies at 86A Georgia Tech football recruit's death on a train track is ruled a suicideCorey Lewandowski drops potential Senate run in New HampshireProjection shows Florida and North Carolina among states that could gain congressional seats after CensusWhat 2020 could bring for the stock marketTexas church security team member who shot gunman had 'eyes' on the man as soon as he walked into the roomOpinion: Texas shooting isn't as simple as it seemsTexas pastor says he knew and helped the gunman before the shootingThe gunman in the Texas church shooting had run-ins with police and had been homeless, his sister saysSonny Mehta, editor-in-chief of Knopf, dies at 77Greyhound is giving free tickets to runaways who want to return homeAn Alabama woman texted 'I feel in trouble' before she disappeared, mother saysAnalysis: A grim end to a dark political year 347 people were killed in Baltimore this year. The mayor pledges to fight the culture of violenceChicago's homicide rate decreases for the third straight yearThe mother of two missing Idaho siblings is not cooperating with investigators, police sayCourt rules against Marc Veyrat in Michelin 'cheddar gate' soufflé caseA mom trying to film her daughter's proposal ended up taking a selfie insteadElizabeth Warren invokes hope in New Year's Eve speech commemorating 2020 launchPete Buttigieg leaves behind economic progress and racial tensions in South BendFact check: Biden makes misleading comments on his past positions on Iraq, Afghanistan warsHe was mocked for proposing in KFC, but the internet found them and will give them their dream weddingOhio doctor charged with killing 25 patients sues hospital for defamationScientist says he's figured out time travelMichelle Williams and 'Hamilton' director Thomas Kail are engaged and expectingCarrie Underwood announces she's stepping down as CMA Awards hostTravis Scott breaks silence over split with Kylie Jenner'Murder Mystery' tops Netflix's most-popular titles of 2019Former tennis champion Margaret Court claims LGBTQ teaching in schools is controlled by 'the devil'Biden would nominate Obama to Supreme Court 'if he'd take it'Linda Ronstadt's vocal genius in 7 songsLinda Ronstadt on the rare brain condition that ended her singing careerTrump's latest call with Putin raises more questions than it answersPutin sent Trump a Christmas and New Year message and invited him again to visit MoscowPutin and Trump spoke by phone to discuss counter-terrorism effortsOpinion: 2020 is prime time for PutinPrince William launches multi-million pound prize to tackle climate crisisTrump and Obama tied for the most admired men in the US this year. Michelle is the most admired woman, Gallup reportsOpinion: The Obama and Trump reading lists, comparedBarack Obama shares his favorite songs of 2019Barack Obama lists his favorite books of 2019Barack Obama's favorite movies and TV shows of 2019The 2010s were relentless. Here are some of the most fascinating news stories that shaped the decade20 things to look forward to in 2020Remembering the decade in political memesHere are 10 of the decade's most influential booksWhen does the decade begin and end anyway?© 2019 Cable News Network. Turner Broadcasting System, Inc. All Rights Reserved.Listen to CNN (low-bandwidth usage)Go to the full CNN experiencewindow.version = "0.19.0" !function(){var analytics=window.analytics=window.analytics||[];if(!analytics.initialize)if(analytics.invoked)window.consol e&&console.error&&console.error("Segment snippet included twice.");else{analytics.invoked=!0;analytics.methods=["trackSubmit","trackClick","trackLink","trackForm","page view ","identify","reset","group","track","ready","alias","de bug" ,"page","once","off","on"];analytics.factory=function(t){return function(){var e=Array.prototype.slice.call(arguments);e.unshift(t);analyti cs.push(e);return analytics}};for(var t=0;t

                          Comment


                            #14
                            I appreciate you sticking with me. I copied preciley your syntax and settings and now I get
                            Not running script since its already running: C:/Program Files (x86)/HomeSeer HS3/scripts/getnews.vb Single instance option enabled in event properties

                            Comment


                              #15
                              Originally posted by wkrasner View Post
                              VB.Net script exception(0), re-starting: Object reference not set to an instance of an object.

                              Yes same error with just writelog
                              If you are getting the same error without the GetUrl statement (in other words, just the writelog statement), then it is something else.

                              Is it possible that some other script is trying to run, or is running, at the same time? The error may be unrelated directly with your script.

                              Hate to ask this, but if you can dump out the actual log with some lines before and after the script, maybe we can spot something.

                              Otherwise, I am not seeing it yet.

                              (This assumes you have made the corrections mentioned above, including adding back "Main" to your subroutine declaration.)

                              Comment

                              Working...
                              X