Announcement

Collapse
No announcement yet.

while trouble

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

    while trouble

    I am having trouble figuring out how to end a while statement in a vb script. Here is what I have:


    y = instr(1,strBody,"<")
    while y <> 0 do
    z = instr(y,strBody,">")
    hs.writelog (log_prefix, "y: " &y& " z: "&z)
    y = instr(y+1,strBody,"<")
    wend



    The log tells me: End of statement expected

    Any thoughts?
    HS Install Date: Feb. 16, 2007

    HS3 Pro, Z-Wave, Insteon, BLStat, HS Touch Server, MyQ

    WeatherXML, BLBackup, BLLAN, BLLock, Restart, CaddX, OpenSprinkler

    #2
    End While

    (instead of wend)
    --
    stipus

    Comment


      #3
      Thanks for the quick response, but that gives the same result.

      I actually tried that as well, I have also commented out the whole while section just to make sure the problem wasn't with another line.

      I can get this to work in .txt scripts, but not in .vb for some reason.
      HS Install Date: Feb. 16, 2007

      HS3 Pro, Z-Wave, Insteon, BLStat, HS Touch Server, MyQ

      WeatherXML, BLBackup, BLLAN, BLLock, Restart, CaddX, OpenSprinkler

      Comment


        #4
        Then End While must be correct, as I get this error if I omit the word while and just use end:

        Script compile error: 'While' must end with a matching 'End While'.on line 61

        So, something else must be wrong after the while but before the end?
        HS Install Date: Feb. 16, 2007

        HS3 Pro, Z-Wave, Insteon, BLStat, HS Touch Server, MyQ

        WeatherXML, BLBackup, BLLAN, BLLock, Restart, CaddX, OpenSprinkler

        Comment


          #5
          got it:

          used the End Whlie as suggested, but also had to remove the "do"
          HS Install Date: Feb. 16, 2007

          HS3 Pro, Z-Wave, Insteon, BLStat, HS Touch Server, MyQ

          WeatherXML, BLBackup, BLLAN, BLLock, Restart, CaddX, OpenSprinkler

          Comment


            #6
            How about using do/until/loop:

            y = instr(1,strBody,"<")
            Do until y = 0
            z = instr(y,strBody,">")
            hs.writelog (log_prefix, "y: " &y& " z: "&z)
            y = instr(y+1,strBody,"<")
            Loop
            Jon

            Comment


              #7
              On this page, you can find the complete reference for VB.NET scripts (.vb).

              http://www.harding.edu/USER/fmccown/...omparison.html

              It's very convenient to get everything listed on one page. I use this quite often.
              --
              stipus

              Comment


                #8
                Great link stipus, I have been using http://www.devguru.com, that is pretty good, but it only shows vb script instead of vb.net. They are close, but not quite the same.
                HS Install Date: Feb. 16, 2007

                HS3 Pro, Z-Wave, Insteon, BLStat, HS Touch Server, MyQ

                WeatherXML, BLBackup, BLLAN, BLLock, Restart, CaddX, OpenSprinkler

                Comment

                Working...
                X