Announcement

Collapse
No announcement yet.

Select Case error. I dont know what i forget.

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

    Select Case error. I dont know what i forget.

    Hi all ,

    // SOLVED SEE LAST POST.
    I forget to dim the name again as double before it could read the case from an ini file and dont give a false positive.









    again i need some help with a error what i don't understand why it doesnt work

    Strbody contains a numer like 84 , i double check it with hs.writelog("test"strbody)

    When i run the full script it goes to case else.
    In case else i added also a hs.writelog ("test",Range1) and hs.writelog ("test",Torange1)

    when i check the output it shows the value from the ini file (50 and 90)
    so thats ok , but the case doesnt work. if i add manual the 50 and 90 it works because Strbody contains the number 84.

    Here the example :

    Code:
    Select Case strBody
    Case Range1 to Torange1
    hs.writelog ("test","Working")
    Case else
    hs,writelog("debug","Range1")
    hs,writelog("debug","Torange1")
    
    
    End Select

    The ini contains this :

    Code:
    [Range]
    Range1=50
    Torange1=90

    Can anyone help me, im very sure im doing it right.
    Last edited by Malosa; September 23, 2017, 02:55 PM. Reason: Solved
    Preferred -> Jon's Plugins, Pushover, Phlocation, Easy-trigger,
    Rfxcom, Blade Plugins, Pushbullet, homekit, Malosa Scripts




    HS3Pro 4.1.14.0 on windows 10 enterprise X64 on hp quadcore laptop 8 GB.

    #2
    That's incorrect use of Case. You are trying to use it like a loop, it's not.

    If you want a loop, to loop through values, then use For Each/Next or Do loops.

    Case requires you to list every case separately. I suggest you search the web for examples... There's thousands of them.

    Sent from my SM-G950U using Tapatalk

    Comment


      #3
      Thanks for the reply,

      Im not using it as a loop ,
      I have many scripts like this... but they dont work anymore...

      this is an example...

      It does read the value correct but the case doesnt work.
      I did it before but somehow it doesnt work anymore...

      I wil explane it again,
      lets say strBody contains the number 84

      and when i look in my ini file i have this value ranges.


      [Range]
      Range1=0
      Torange1=90
      Range1=100
      Torange1=200
      Range1=201
      Torange1=300
      Range1=301
      Torange1=400
      Range1=401
      Torange1=500

      Why when i run my script it does not work? range1 to Torange1 contains 0 - 90

      when i change Range1 to 0 and Torange1 90 it works

      so homeseer should read it like this Case 0 to case 90, When it goes to case else i let it write a log if it can read the values of range1 and torange1 and it writes out perfectly like 0 and 90....



      So my question is why does it not work while it can read all values...


      Code:
      Select Case strBody
      Case Range1 to Torange1
      hs.writelog ("test","Working1")
      Case Range2 to Torange2
      hs.writelog ("test","Working2")
      Case Range3 to Torange3
      hs.writelog ("test","Working3")
      Case Range4 to Torange4
      hs.writelog ("test","Working4")
      Case Range5 to Torange5
      hs.writelog ("test","Working5")
      Case Range6 to Torange6
      hs.writelog ("test","Working6")
      Case else
      hs,writelog("debug","Range1")
      hs,writelog("debug","Torange1")
      
      
      End Select

      Originally posted by Ltek View Post
      That's incorrect use of Case. You are trying to use it like a loop, it's not.

      If you want a loop, to loop through values, then use For Each/Next or Do loops.

      Case requires you to list every case separately. I suggest you search the web for examples... There's thousands of them.

      Sent from my SM-G950U using Tapatalk
      Preferred -> Jon's Plugins, Pushover, Phlocation, Easy-trigger,
      Rfxcom, Blade Plugins, Pushbullet, homekit, Malosa Scripts




      HS3Pro 4.1.14.0 on windows 10 enterprise X64 on hp quadcore laptop 8 GB.

      Comment


        #4
        Its solved .

        This happens everytime i want to post something on the forum for help.

        If anyone has the same problem u can solve it with this line :

        Code:
         dim checks as double
        		checks = strBody

        The only thing was to give strbody an other name to dim as double and its fixed finaly after 6 hours of trying.
        Preferred -> Jon's Plugins, Pushover, Phlocation, Easy-trigger,
        Rfxcom, Blade Plugins, Pushbullet, homekit, Malosa Scripts




        HS3Pro 4.1.14.0 on windows 10 enterprise X64 on hp quadcore laptop 8 GB.

        Comment

        Working...
        X