Announcement

Collapse
No announcement yet.

Passing Variables Using Events

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

  • Passing Variables Using Events

    I am a modest VB programmer and have been able to write some scripts that run successfully. With that said I am having difficulty figuring something out.

    Every Sunday between 3AM and 9:30AM I need to have my HSTouch devices (Android) speak reminders at 21 distinct times with 21 different messages. I have created 21 events that trigger another event that plays an hs.speak function script but I am trying to avoid writing 21 different events and scripts for the individual spoken messages.

    I was hoping that in each of my trigger events I could load the text to be spoken into a variable, pass that variable to a single hs.speak script that would extract the variable and speak the text. In this way I would have 21 event triggers and a single hs.speak script.

    Creating and passing the variable is confounding me. Also, is it possible to reference a variable with hs.speak i.e., hs.speak (variable) instead of hs.speak "This is the actual text". I am able to reference a wav file with hs.speak but then I'll have to create 21 different wav files.

    Thanks in advance for any suggestions you may offer.


    Jim

  • #2
    Look under Tools - Global variables.
    Is that you want?
    They are also usable in events and i believe that you can also use them as a replacement variable. But i am not sure about the last one. See the help file more that one.

    Comment


    • #3
      Global variables are not persistent. They must be declared any time HS is started. For my TTS string variables, I prefer to keep them in the string of a virtual device. I keep my salutation (good morning, good afternoon, good evening) in one and variable messages in others. Then I use replacement variables in the text string used in TTS. Another value of using a virtual device instead of a global variable is that it is something you can look at with the device manager to see the contents.
      Randy Prade
      Aurora, CO
      Prades.net

      PHLocation - Pushover - EasyTrigger - UltraECM3 - Ultra1Wire3 - Arduino

      Comment


      • #4
        Global Variable

        I do see the global variables but have been unable to determine how to load one from an event. It looks to me like I have to write a script that will load the variable and call the script from the event. In this case I am again writing 21 more scripts which is what I am trying to avoid.

        Comment


        • #5
          Why not just use the script parameter to select the message i.e.

          Code:
              Sub Main(ByVal Choice As Integer)
                  Dim Message As String = ""
                  Select Case Choice
                      Case 1
                          Message = "This is message 1"
                      Case 2
                          Message = "This is message 2"
                      Case 3
                          Message = "This is message 3"
                      Case 4
                          Message = "This is message 4"
                      Case 5
                          Message = "This is message 5"
                      Case 6
                          Message = "This is message 6"
                      Case 7
                          Message = "This is message 7"
                      Case 8
                          Message = "This is message 8"
                          '
                          '
                          '
                      Case 21
                          Message = "This is message 21"
                  End Select
          
                  If Message <> "" Then hs.speak(Message)
              End Sub
          Just use each event to run this script but change the script parameter in the event to 1 or 2 or 3 etc as necessary.
          Jon

          Comment


          • #6
            Passing Information from Event to Script

            rprade and jon00,

            Both suggestions are great and I am experimenting with them now. In order to pass information out of an event and into a script I am loading a device string with the text I need and then parsing it into a script variable on the other side using hs.SetDeviceString.

            jon00 implies that hs.speak will speak the variable and I will soon find out.

            Thanks, and I will report my results soon.

            Comment


            • #7
              I've noticed that since version .455 replacement variables aren't working anymore

              Comment


              • #8
                Originally posted by jimbtv View Post
                rprade and jon00,

                Both suggestions are great and I am experimenting with them now. In order to pass information out of an event and into a script I am loading a device string with the text I need and then parsing it into a script variable on the other side using hs.SetDeviceString.

                jon00 implies that hs.speak will speak the variable and I will soon find out.

                Thanks, and I will report my results soon.
                It sound like you are making this far more complicated than it needs to be. Can you provide an example of the text you want to pass to your script to announce? Does this text change or is it always fixed?
                Jon

                Comment


                • #9
                  Originally posted by jon00 View Post
                  It sound like you are making this far more complicated than it needs to be. Can you provide an example of the text you want to pass to your script to announce? Does this text change or is it always fixed?
                  First I'd like to say that everything is working now, and thanks for the tips.

                  jon00, I bake bread on Sunday mornings between 2:45AM and around 11AM. I have to turn out 60 baguettes in that time period starting from scratch, so no cold ferments or cold proofing. Since I bake 12 at a time I have to run this highly synchronized affair where timing is absolutely critical. I set up 21 events that serve as reminders of progress, and markers for starting processes.

                  Every message has a different text, such as "Mix 1 Start", "Mix 2 Stretch and Fold", or "Mix 3 Shape" to show some examples. I also push visual text messages to the Android devices I have located in different spots. Once these TTS messages are initiated (by day and time), I want the message to repeat every 10 seconds until I push the "Acknowledge" button on any Android device. Like others have commented about TTS, sometimes you miss the first pass because you are distracted.

                  At specified trigger times I push a text message, start a timer, advance a device's value to something greater than zero, and place my text in device string. I do this for all 21 events. Another event looks for a device value greater than zero, sees if the time is still counting up, and if so it calls the script. The script pulls the string into a local variable and I place that variable right after the hs.speak command.The text is spoken and then the called event waits 10 seconds before checking the conditions again. If they are as stated above, the TTS message plays again.

                  Pressing the acknowledge button on my HSTouch Androids stops the timer, resets it to zero, and returns the value in the device to zero. That is the end of the sequence until the next time event triggers.

                  I hope that clarifies my needs and again, thanks for the help.

                  Comment

                  Working...
                  X