Announcement

Collapse
No announcement yet.

Passing values to a script-Problems

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Passing values to a script-Problems

    I'm trying to pass several list box values from HSTouch and I'm getting strange characters from the result.


    Thursday520PM


    The above passes a selected list of days, hours, minutes, and AM or PM. When I created the list boxes, I used strings for the List_Labels and numeric for the List_values, but it appears only to be passing the
    strings in the List_Labels.


    I'm sure they are special characters to break up the string, but I can't identify them to use a split() function. Ironically, when I tried to post the string here if
    formats without the separators.

    Also how do I pass the values, not the strings?
    Don

    #2
    Pass the string equivalent of the numbers.

    Don't try to send 6, send "6", then convert "6" to 6 inside your script.

    I use the semicolon as the separator.

    "A busy day;2; 5AM;Get Up;10PM;Go to sleep"

    Then split based on the ';' delimiter, convert "2" to 2.
    huggy_d1

    Automating made easy

    Comment


      #3
      Thanks for the reply.

      Sorry I wasn't clear. In HSTouch I have four list boxes. There is a button that calls a script using the selected items in those four list boxes.

      ie..
      ScriptParameter1 is set to Day Drop Down List
      ScriptParameter2 is set to Hour Drop Down List

      well, you get the idea. When the button is pushed it passes the selections in the four drop down boxes with characters between the list selections and there appears to be a terminator character at the end of the string.
      I need to pull out the selected text from the string that is passed to the
      script, but I don't know what the characters are that split the string.



      Originally posted by huggy_d1 View Post
      Pass the string equivalent of the numbers.

      Don't try to send 6, send "6", then convert "6" to 6 inside your script.

      I use the semicolon as the separator.

      "A busy day;2; 5AM;Get Up;10PM;Go to sleep"

      Then split based on the ';' delimiter, convert "2" to 2.
      Don

      Comment


        #4
        Whilst I can't really help you I suffer with the same, I have the box symbol (can't find it in character map at the moment) that turns up in mine. It always is at the end of the string so I was going to do a right(data,1) just to take off the last character but there probably is a better solution.

        Comment


          #5
          Originally posted by mrhappy View Post
          Whilst I can't really help you I suffer with the same, I have the box symbol (can't find it in character map at the moment) that turns up in mine. It always is at the end of the string so I was going to do a right(data,1) just to take off the last character but there probably is a better solution.
          You should not have to parse them. Unlike HS HST passes variables as a array of objects. Each list box value is avaliable as a seperate object.

          Sub Main(pParms As Object)
          Dim Y as Integer

          For Y = 0 to UBound(pParms)
          hs.WriteLog("Rod", pParms(Y))
          Next

          Gerard
          Last edited by Gerard; January 15, 2010, 08:01 PM.

          Comment


            #6
            According to the string that Don posted those 2 characters 7 and 4 ascii between each value.
            💁‍♂️ Support & Customer Service 🙋‍♂️ Sales Questions 🛒 Shop HomeSeer Products

            Comment


              #7
              Actually ignore me, I remember correctly now (it's late) - I see this on printouts rather than in anything else, does not cause me a major problem I just posted whilst you were on the subject.

              Comment


                #8
                OK, that makes things manageable. Still have the little square box thing, but that is doable. Thanks to all for the suggestions.

                Originally posted by Gerard View Post
                You should not have to parse them. Unlike HS HST passes variables as a array of objects. Each list box value is avaliable as a seperate object.

                Sub Main(pParms As Object)
                Dim Y as Integer

                For Y = 0 to UBound(pParms)
                hs.WriteLog("Rod", pParms(Y))
                Next

                Gerard
                Don

                Comment


                  #9
                  If you still have the character then use the replace function to replace ASCII chars 2 and 7 with nothing.
                  💁‍♂️ Support & Customer Service 🙋‍♂️ Sales Questions 🛒 Shop HomeSeer Products

                  Comment


                    #10
                    The reason it is passed as a single string is because the receiving script could be VBS or VB.NET, and VBS cannot receive an array of objects - it is a single string parameter only.

                    The parameters are concatenated together, separated by a Chr(4) character, and then passed to the script. So, split based upon Chr(4) and you will have your different parameters. Then, if the original parameter came from a drop down list as in this case, the label and the value are separated by Chr(7).

                    So for example, your drop downs might produce something like this:

                    Thursday(7)5(4)5(7)5(4)20(7)20(4)PM(7)1

                    Which when split by 4 is:
                    Thursday(7)5
                    5(7)5
                    20(7)20
                    PM(7)1

                    And then each of those is your text and value from the drop down list.

                    I made sure that this information is being added to the help file since it was not there.
                    Regards,

                    Rick Tinker (a.k.a. "Tink")

                    Comment


                      #11
                      Rick
                      Thanks. There is a sticky in the HSTouch area on scripting that would benifit from this fine explanation also.

                      Thanks
                      Gerard

                      Comment


                        #12
                        Rick
                        Sorry to be a pain but I can not get a vb.net script to receive the text of 2 label elements from HST as a single string as you sugest. It only apears to work for me as 2 objects. Can you provide a example VB.NET script that works like you showed? Below is the only thing that works for me.



                        Sub Main(pParms As Object)
                        Dim Y as Integer

                        For Y = 0 to UBound(pParms)
                        hs.WriteLog("Rod", pParms(Y))
                        Next

                        Comment


                          #13
                          Originally posted by Gerard View Post
                          Rick
                          Sorry to be a pain but I can not get a vb.net script to receive the text of 2 label elements from HST as a single string as you sugest. It only apears to work for me as 2 objects. Can you provide a example VB.NET script that works like you showed? Below is the only thing that works for me.
                          Can you please re-post this into the HSTouch forum? I will ask Rich to look at it and respond, but it is HSTouch related, not specifically scripting.

                          Verify though that your first object is not a string - we use objects in .NET scripts because they can hold any variable type, so in your WriteLog statements, are you seeing data or are you getting an error? If you are getting an error, you should change pParms(Y) to pParms(Y).ToString and see if it shows information.
                          Regards,

                          Rick Tinker (a.k.a. "Tink")

                          Comment


                            #14
                            Oh wow that was stupid - this is in the HSTouch forum! I just clicked the link and did not realize you moved it... sorry!

                            See what my last info does and I will ask Rich to comment if he knows specifics about this.
                            Regards,

                            Rick Tinker (a.k.a. "Tink")

                            Comment


                              #15
                              Originally posted by Rick Tinker View Post
                              Can you please re-post this into the HSTouch forum? I will ask Rich to look at it and respond, but it is HSTouch related, not specifically scripting.

                              Verify though that your first object is not a string - we use objects in .NET scripts because they can hold any variable type, so in your WriteLog statements, are you seeing data or are you getting an error? If you are getting an error, you should change pParms(Y) to pParms(Y).ToString and see if it shows information.
                              The script works as is without the .tostring. It looks like I am recieving an array of objects of type string.
                              Last edited by Gerard; January 22, 2010, 12:01 PM.

                              Comment

                              Working...
                              X