Announcement

Collapse
No announcement yet.

Touch Toggle Button to do script

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

    Touch Toggle Button to do script

    Hello

    Please can someone tell me how I can make a button toggle between script commands?

    So command :
    hs.getURL(do something A...)
    hs.getURL(do something B...)

    Thank you
    Last edited by smokeycoles; June 4, 2016, 03:19 AM.

    #2
    Code:
    '=========================================================================
    'First Script
    '=========================================================================
    Sub Main(parm as object)
    
    Public cruise_toggle As Boolean
    
    hs.writelog("Horizontal Scroll","Horizontal Scroll Variable is: " & cruise_toggle)
    
    If cruise_toggle = False Then
    	hs.GetUrl("http://192.168.1.51:80/cgi-bin/CGIProxy.fcgi?cmd=ptzStartCruise&mapName=Horizontal&usr=***&pwd=***","",True,80)
    cruise_toggle = True
    
    Else If cruise_toggle = True Then
    	hs.GetUrl("http://192.168.1.51:80/cgi-bin/CGIProxy.fcgi?cmd=ptzStopCruise&usr=***&pwd=***","",True,80)
    cruise_toggle = False
    
    Else
    hs.writelog("Horizontal Scroll","Error")	
    
    End If
    
    End Sub
    The problem is the variable declaration I believe?
    If I set it to Dim - it is always False.
    I think this is because of the scope of the method each time the button ends; the DIM value ends.

    Please help?

    Comment


      #3
      Do you get an error or does it not do what you are after, the cruise_toggle is never given a value so will be the default and the .net default for boolean is false. As such only the first statement will run, you can change it by putting in

      cruise_toggle = True

      and it should jump to the next one, you can also drop the ElseIf as boolean will only ever be true/false (it can't have a third state) so an If...Then...Else will do just fine.

      Comment


        #4
        Hi

        Thank you for responding.
        I thought I was the only one on here for a minute

        I have managed it now - just had to put it outside the sub function.
        I am a little more use to Java so that's not common practice for me.


        Code:
        Dim cruise_toggle As Boolean
        
        Sub Main(parm As Object)
        End Sub
        
        Sub HorrizontalScroll(IPaddress As String)
        
        hs.writelog("Horizontal Scroll","Horizontal Scroll Variable for camera " & IPaddress & " is: " & cruise_toggle)
        
        If cruise_toggle = False Then
        	hs.GetUrl("http://" & IPaddress & "/cgi-bin/CGIProxy.fcgi?cmd=ptzStartCruise&mapName=Horizontal&usr=***&pwd=***","",True,80)
        cruise_toggle = True
        
        Else If cruise_toggle = True Then
        	hs.GetUrl("http://" & IPaddress & "/cgi-bin/CGIProxy.fcgi?cmd=ptzStopCruise&usr=***&pwd=***","",True,80)
        cruise_toggle = False
        
        Else
        hs.writelog("Horizontal Scroll","Error")	
        
        End If
        
        End Sub
        I could do with some help though in HSTouch. The Event works in HS3 web interface events.

        I have set my button to event and to the script and changed the sub function correctly.

        When I go to parameter 1 - I try to type 192.168.1.51:80
        HSTouch then clears my text, I have a drop list of labels..
        Is there a way just to type something in? Very confusing!
        Attached Files

        Comment


          #5
          No there is no way to type something in the ScriptParameter1 box, it is expecting the value to be passed from an element (drop list/text box etc). You can instead either put the values in an element on a hidden screen (so you can update them easier - or hide the elements) and pass them in or you used to be able instead in the script box to type the HS3 equivalent of &hs.runex("scriptname.vb","ScriptParam","Test here") so essentially an immediate script command - check the help file for the HS3 script running syntax though.

          Comment


            #6
            I like the idea of a hidden screen - to easily change values.
            That's great, I will do that.

            I actually changed my mind, going to make events in HS3 then they can be called from other things/events.
            HSTouch won't need deploying each time too.

            Thank you
            Last edited by smokeycoles; June 4, 2016, 04:12 AM.

            Comment

            Working...
            X