Announcement

Collapse
No announcement yet.

Pull a value from Textbox in Hstouch

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

  • Pull a value from Textbox in Hstouch

    Has anyone been able to successfully pull a value back to HS3 from an Hstouch textbox? i can do it with drop downs and text elements but no matter what I try with a textbox i just get an error.

  • #2
    I needed to do that as well. The only solution I found was to send text elements as parameters via scripts.

    Hope that helps.

    Jeff

    Comment


    • #3
      Anyway I could get you to send me a copy of how you set that up? I am able to do that from other elements such as drop downs and simple text elements, but when i try with a textbox it just errors out.

      Comment


      • #4
        First I created hidden text elements. For the purpose of demonstration, they are un-hidden here. I allowed presses on the text box and when released, it first sets the text element as seen below - in this case, it's called UserID:

        Click image for larger version

Name:	Pass Element 1.PNG
Views:	23
Size:	418.9 KB
ID:	1279561

        Then it passes the element UserID string to a script, in this case EditUserPhone.vb

        Click image for larger version

Name:	Pass Element 2.PNG
Views:	12
Size:	441.8 KB
ID:	1279562

        Then the script receives the passed string in parm(0), and parm(1) if there's a second variable being passed, then manipulates a virtual device in HS3:

        Code:
        'HS3 Script 2019-01-15  JG
        Sub Main(ByVal parm As Object)
        
            Dim inputphone, UserNo, UserPhone, UserPass
            inputphone = parm(1).ToString ' Get new user name from HSTouch
            UserNo = parm(0).ToString ' Get new user number from HSTouch
            UserPhone = "User" & UserNo & "Phone"
            UserPass = "User" & UserNo & "Phone"
        
            If Len(inputphone) <>10 Then
                hs.Speak("Phone Number must be at 10 characters")        
                hs.SaveINISetting("Users", UserPhone, "N/A", "configfile.ini")
        '        hs.SetDeviceStringByName(UserPhone,"Off",true)
            Else
                hs.SaveINISetting("Users", UserPhone, inputphone, "configfile.ini")
        '        hs.SetDeviceStringByName(UserPhone,inputphone,true)
                hs.Speak("User " & UserNo & " Phone changed sucessfully")        
                hs.writelog("Security",CStr("User " & UserNo & " Phone changed to: " & inputphone))
            End If
        
        End Sub
        In my case, I am editing the values in an .ini file, but the command to change a virtual device is the commented out one using hs.SetDeviceStringByName

        Hope this helps.

        Jeff

        Comment


        • #5
          Ugh I keep getting the same error every time even setting it up like that.

          Running script Cookie.vb :Exception has been thrown by the target of an invocation.->Does entry point Main exist in script? at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Obj ect obj, Object[] parameters, Object[] arguments) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at Scheduler.clsRunVBNetScript.ExecuteScript()

          Comment


          • #6
            I'm sorry, but I am not familiar with the error, maybe one of the more experienced HS3 people on here can help, but, this could be the issue...

            My example was for passing 2 parameters from HSTouch, how many are you sending?

            If you copied my code exactly and you are only sending one parameter to the script, it will fail. The first parameter is parm(0), the second is parm(1), and so on. If you only have one parameter then delete the parm(1) line.

            Comment


            • #7
              nah thats not it i tried passing just one and two just to be sure my script literally just assigning value to a variable then not doing anything right now. Everything else works great just missing this one piece.

              Originally posted by jgreenberg01 View Post
              I'm sorry, but I am not familiar with the error, maybe one of the more experienced HS3 people on here can help, but, this could be the issue...

              My example was for passing 2 parameters from HSTouch, how many are you sending?

              If you copied my code exactly and you are only sending one parameter to the script, it will fail. The first parameter is parm(0), the second is parm(1), and so on. If you only have one parameter then delete the parm(1) line.

              Comment

              Working...
              X