Announcement

Collapse
No announcement yet.

HS3 (.44) Stringitem was officially removed!

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

    HS3 (.44) Stringitem was officially removed!

    Hi,

    When using hs.stringitem in the following code I get an error message:
    Error 1 Running script C:\Program Files\HomeSeer HS3\scripts\test-new.vb :Exception has been thrown by the target of an invocation.Public member 'StringItem' on type 'hsapplication' not found.
    Any idea what the problem is? I searched for stringitem in the HS3 forum but did not find anything.

    HTML Code:
    Imports System.IO
    
    Public Sub Main(ByVal Parms As Object)
        Dim arrTest as String
        Dim strFirst,strSecond as String
            
        hs.writelog("test","writelog working")
        arrTest = "ABC,DEF"
        strFirst  = hs.StringItem(arrTest,1,",")
        strSecond = hs.StringItem(arrTest,2, ",")
        
        hs.writelog("result","strFirst:" & strFirst)
        hs.writelog("result","strFirst:" & strFirst)
    
    End Sub

    #2
    I would recommend switching over to the vb.net split function as it's faster.
    💁‍♂️ Support & Customer Service 🙋‍♂️ Sales Questions 🛒 Shop HomeSeer Products

    Comment


      #3
      Originally posted by DJF3 View Post
      Hi,

      When using hs.stringitem in the following code I get an error message:
      Error 1 Running script C:\Program Files\HomeSeer HS3\scripts\test-new.vb :Exception has been thrown by the target of an invocation.Public member 'StringItem' on type 'hsapplication' not found.
      Any idea what the problem is? I searched for stringitem in the HS3 forum but did not find anything.

      HTML Code:
      Imports System.IO
      
      Public Sub Main(ByVal Parms As Object)
          Dim arrTest as String
          Dim strFirst,strSecond as String
              
          hs.writelog("test","writelog working")
          arrTest = "ABC,DEF"
          strFirst  = hs.StringItem(arrTest,1,",")
          strSecond = hs.StringItem(arrTest,2, ",")
          
          hs.writelog("result","strFirst:" & strFirst)
          hs.writelog("result","strFirst:" & strFirst)
      
      End Sub
      I found that as well, and since it's just a simple string Sub command, I just use Split

      Public Sub Main(ByVal Parms As Object)
      Dim arrTest, strFirst,strSecond as String
      Dim results() as String

      arrTest = "ABC,DEF"
      results = arrTest.Split(",")
      strFirst = results(0)
      strSecond = results(1)
      hs.writelog("result","strFirst:" & strFirst)
      hs.writelog("result","strSecond:" & strSecond)

      End Sub

      Comment


        #4
        Thank you for your suggestions!

        So is hs.stringitem broken? It looks like I'm using it correctly.

        Comment


          #5
          Originally posted by DJF3 View Post
          Thank you for your suggestions!

          So is hs.stringitem broken? It looks like I'm using it correctly.
          I can't find the note, but I remember reading that some hs. functions were not ported because the equivalent functions were easily accomplished in vb.net. I think hs.stringitem was one of those.

          I do know I had to modify a couple of scripts.

          Barry

          Comment


            #6
            Originally posted by lhfarm View Post
            I can't find the note, but I remember reading that some hs. functions were not ported because the equivalent functions were easily accomplished in vb.net. I think hs.stringitem was one of those.

            I do know I had to modify a couple of scripts.

            Barry
            I seem to remember that too, but it looks like hs.StringItem was not depricated in HS3. I would suggest posting a bug report.

            Here's a link to the HS3 scripting docs: http://homeseer.com/support/homeseer...lp/default.htm
            Code:
            [B]StringItem[/B]
            
            [B]Purpose[/B]
            This function retrieves the substring from a string.  Given a string like "data;data1;data2", this function will retrieve the string at the specified index.  For instance, passing the index as 2 would return the string "data1".
            
            [B]Parameters[/B]
            Parameter: str
            Type: string
            Description: This is the string to search in.
            
            Parameter: index
            Type: long
            Description: This is the number of the string you wish returned. 1=string 1,2=string 2, etc.
            
            Parameter: sep
            Type: string
            Description: This is the string that separates all other strings.
            
            [B]Returns[/B]
            Return value: string part
            Type: string
            Description: This is the part of the string requested.
            Best regards,
            -Mark-

            If you're not out on the edge, you're taking up too much room!
            Interested in 3D maps? Check out my company site: Solid Terrain Modeling

            Comment


              #7
              StringItem not working

              I just ran into this too. Is someone creating a bug report to have it removed from the Documentation?

              Are there any other functions documented that no longer work (like hs.GetEventEX) that should be removed from the docs?

              I've spent several hours over the past couple days trying to figure out why I couldn't get these two functions working....

              Thanks,

              --Doug

              Comment


                #8
                Rick confirmed in the developers forum about 6 months ago that hs.Stringitem was not going to be included in HS3.

                If you want a drop in replacement use the following:

                PHP Code:
                Function Stringitem(ByVal Str As StringByVal Index As IntegerByval Sep As String) As String
                Try
                Dim Result() As String System.Text.RegularExpressions.Regex.Split(StrSystem.Text.RegularExpressions.Regex.Escape(Sep))
                Return 
                Result(Index-1)
                Catch
                Return 
                ""
                End Try
                End Function 
                change your hs.Stringitem code to Stringitem
                Jon

                Comment


                  #9
                  I have a note on this, I will remove it from the docs.

                  We did remove it from the API since vb.net has better ways to handle it. That function was added way back when HS was VB6.
                  💁‍♂️ Support & Customer Service 🙋‍♂️ Sales Questions 🛒 Shop HomeSeer Products

                  Comment


                    #10
                    I appreciate the responses. My key concern was the possibility of other functions that are documented but not functional/supported/working in HS3.

                    I discovered the two I mentioned above the hard way, and would like to avoid un-necessary debugging effort in the future.

                    Rich - do you have a list of documented but non-working functions in HS3? I am aware of 3 so far...


                    Thanks,

                    --Doug

                    Comment


                      #11
                      This was published just before the developers preview of HS3:

                      AddAction will be missing
                      AddCondtion will be missing
                      CAPIHandleStatus will be missing
                      ClearConditions will be missing
                      ClearLastX10 will be missing
                      ControlThermostat will be missing
                      DeviceStatus will be missing
                      DeviceString Exists, but parameter changed to REF
                      DeviceTime Exists, but parameter changed to REF
                      DeviceValue Exists, but parameter changed to REF
                      DeviceValuesAdd Exists, but parameters changed
                      DeviceValuesGraphicsAdd Exists, but parameter changed
                      DeviceLastChange Needs to change to use REF
                      DeviceExists Needs to change to use REF
                      DialInternetConnection will be missing
                      DisconnectInternetConnection will be missing
                      ExecX10 will be missing (use CAPI interface instead)
                      ExecX10ByName will be missing
                      ExecX10NoLog will be missing
                      GetDeviceEnumerator Limited support (many device properties changed)
                      GetDeviceEx Limited support (many device properties changed)
                      GetDeviceCode Returns technology dependent code
                      GetEventByRef Issues with accessing events directly.
                      GetEventEnumerator will be missing
                      GetEvent will be missing, replaced with GetEventEx (issues with accessing events directly)
                      GetEventEx Issues with accessing events directly.
                      GetTVGTData will be missing
                      GetURLIE only works on Windows, not Linux
                      InstallScript will be missing
                      InterfaceVersion changes from 3 to 4
                      IsDialUpConnected will be missing
                      IsOff will be missing
                      IsOn will be missing
                      keys Windows Only, not Linux
                      lastx10 will be missing
                      NewCondition will be missing
                      NewEventAction will be missing
                      NewEventEx will be missing
                      NewEventGetRef will be missing
                      NewRecurringEvent will change
                      NewTimeEvent will change
                      PollDevice will be missing
                      PrintOut will be missing
                      PrintOutRaw will be missing
                      RunningAsService will be missing
                      SetDeviceLastChange will be missing
                      SetDeviceStatus will be missing
                      SetDeviceStatusByName will be missing
                      SetDeviceString parameter changed to REF
                      SetDeviceTime parameter changed to REF
                      SetDeviceValue parameter changed to REF
                      SetDeviceValueEx parameter changed to REF
                      SetSecurityMode parameter changed to Boolean
                      Transmit parameters will change
                      X10InterfaceStatus will be missing
                      Jon

                      Comment


                        #12
                        Is there going to be a HS3 scripting section on the forum?
                        I use all x10 and about 60-70% .txt scripts right now.
                        After looking at the list Jon00 posted, I am going to be in trouble.

                        Thanks,
                        Tim
                        FB Page - https://www.facebook.com/pages/Capt-Tim/209398425902188

                        HSTouch Layouts - https://www.facebook.com/media/set/?...5902188&type=3

                        Comment


                          #13
                          Good idea, I created a HS3 Scripting forum under the Development->Scripting section.

                          Originally posted by fungun View Post
                          Is there going to be a HS3 scripting section on the forum?
                          I use all x10 and about 60-70% .txt scripts right now.
                          After looking at the list Jon00 posted, I am going to be in trouble.

                          Thanks,
                          Tim
                          💁‍♂️ Support & Customer Service 🙋‍♂️ Sales Questions 🛒 Shop HomeSeer Products

                          Comment


                            #14
                            I am reviewing the docs, right now I am not aware of any other functions, but there could be some. I'll post if I find any.

                            Originally posted by dwoolridge View Post
                            I appreciate the responses. My key concern was the possibility of other functions that are documented but not functional/supported/working in HS3.

                            I discovered the two I mentioned above the hard way, and would like to avoid un-necessary debugging effort in the future.

                            Rich - do you have a list of documented but non-working functions in HS3? I am aware of 3 so far...


                            Thanks,

                            --Doug
                            💁‍♂️ Support & Customer Service 🙋‍♂️ Sales Questions 🛒 Shop HomeSeer Products

                            Comment

                            Working...
                            X