Announcement

Collapse
No announcement yet.

hs.StringItem replacement

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

    hs.StringItem replacement

    I have a HS2 script I'd like to convert to HS3 but noticed that hs.StringItem no longer exists. Can someone suggest a workaround to the section below which uses it?


    PHP Code:
    For I=0 to UBound(section_items)
            
    Dim the_date_time As String
                    Dim the_name 
    As String
                    Dim the_note 
    As String
            the_date_time 
    hs.StringItem(section_items(I),1,"=")
                    
    the_name hs.StringItem(section_items(I),2,"=")
            
    the_note hs.StringItem(section_items(I),3,"=")
                    If 
    the_name "SUMP OFF" Then
                         dev_string 
    dev_string "<img src=\MyImgs\led-red.gif> <small>" the_name " @ " the_date_time " " the_note "</small> <br>"
                     
    Else
                         
    dev_string dev_string "<img src=\MyImgs\led-green.gif> <small>" the_name " @ " the_date_time " " the_note "</small> <br>"
                    
    End If
            
    Next 
    Thanks,

    Robert
    HS3PRO 3.0.0.500 as a Fire Daemon service, Windows 2016 Server Std Intel Core i5 PC HTPC Slim SFF 4GB, 120GB SSD drive, WLG800, RFXCom, TI103,NetCam, UltraNetcam3, BLBackup, CurrentCost 3P Rain8Net, MCsSprinker, HSTouch, Ademco Security plugin/AD2USB, JowiHue, various Oregon Scientific temp/humidity sensors, Z-Net, Zsmoke, Aeron Labs micro switches, Amazon Echo Dots, WS+, WD+ ... on and on.

    #2
    Check out the .net split function. It's nearly identical.
    https://www.dotnetperls.com/split-vbnet
    💁‍♂️ Support & Customer Service 🙋‍♂️ Sales Questions 🛒 Shop HomeSeer Products

    Comment


      #3
      When HS3 first came out, I wrote a function to replicate hs.Stringitem.

      Place the following code at the bottom of your script. Then change any references in your script from hs.StringItem to just Stringitem.

      Code:
      Function Stringitem(ByVal Str As String, ByVal Index As Integer, Byval Sep As String) As String
      Try
          Dim Result() As String = System.Text.RegularExpressions.Regex.Split(Str, System.Text.RegularExpressions.Regex.Escape(Sep))
          Return Result(Index-1)
      Catch
          Return ""
      End Try
      End Function
      Jon

      Comment


        #4
        Thank you very much Jon!

        It works perfectly..

        Robert
        HS3PRO 3.0.0.500 as a Fire Daemon service, Windows 2016 Server Std Intel Core i5 PC HTPC Slim SFF 4GB, 120GB SSD drive, WLG800, RFXCom, TI103,NetCam, UltraNetcam3, BLBackup, CurrentCost 3P Rain8Net, MCsSprinker, HSTouch, Ademco Security plugin/AD2USB, JowiHue, various Oregon Scientific temp/humidity sensors, Z-Net, Zsmoke, Aeron Labs micro switches, Amazon Echo Dots, WS+, WD+ ... on and on.

        Comment

        Working...
        X