Author Topic: Building a complex Conditional Statement  (Read 4282 times)

Mike308

  • Newbie
  • *
  • Posts: 48
Building a complex Conditional Statement
« on: November 09, 2017, 07:51:56 PM »
Making my first foray into more advanced programming in VA. I received a kind assist from Pfeil on how to build a conditional response to a "what time is it" question. Before anybody suggests a simpler, more elegant TTS answer to simply read the precise time, I am building a recorded-voice profile so I need to go through this one laborious command. (yes, the example below has a TTS placeholder, but those will ultimately be replaced with Play Sound commands.)

I have divided an hour into four quarters because I only need a rough sense of time. So each of 24 hours follows this format:

Begin Text Compare : [{EXP: {TIMEHOUR24}{TIMEMINUTE}  >= 2353 And {TIMEHOUR24}{TIMEMINUTE}  <= 0007}] Equals '1'
    Say, ‘Its around midnight’
Else If Text Compare : [{EXP: {TIMEHOUR24}{TIMEMINUTE}  >= 0008 And {TIMEHOUR24}{TIMEMINUTE}  <= 0022}] Equals '1'
    Say, ‘Bout quarter past twelve’
Else If Text Compare : [{EXP: {TIMEHOUR24}{TIMEMINUTE}  >= 0023 And {TIMEHOUR24}{TIMEMINUTE}  <= 0037}] Equals '1'
    Say, ‘Call it twelve-thirty’
Else If Text Compare : [{EXP: {TIMEHOUR24}{TIMEMINUTE}  >= 0038 And {TIMEHOUR24}{TIMEMINUTE}  <= 0052}] Equals '1'
    Say, ‘Bout quarter to one’


That makes for a lot of lines. My question is this: Do I need to build this one line at a time using the Command Builder, or is there a lazy man's way to copy/paste the entire block in one pass?  Many thanks in advance!

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4785
  • RTFM
Re: Building a complex Conditional Statement
« Reply #1 on: November 09, 2017, 08:03:04 PM »
I'm not sure I understand the question correctly, but you can copy and paste what you have, then change the parameters(E.G. start time, end time, and sound response) for individual actions by editing them in the condition builder; This does come with the limitation that the logic must still match up, I.E. you can't copy the "Begin Text Compare" action and paste it into the middle of the condition.

There is no inherent order or connection between actions within VoiceAttack; As long as the order of Begin-Else-End for conditional blocks is observed, you can copy-paste whatever you need, even from different commands or profiles.

Gangrel

  • Caffeine Fulled Mod
  • Global Moderator
  • Full Member
  • *****
  • Posts: 216
  • BORK FNORK BORD
Re: Building a complex Conditional Statement
« Reply #2 on: November 09, 2017, 08:08:40 PM »
Shift+left click should select lines, and then right click copy.

you can then paste this as many times as needed, altering just the relavent parts.

Side note: Probably makes more sense to do the "working out" in one command, and then using the results as the input for another command (which does the speech part).

The main part appears to be the "timeminute" section, so if you do the >=53 and <=07 (for example) (8 lines) for example)

Then all you need to do is another builder which is the hour "calculator" (say, 48 lines).

Instead of doing a complete 8x24 = 168 lines, it would be less than that.

Side note: Also means that if you want to go even finer with the time (ie if you wanted to add in 5 minute intervals for example), then you would only need to work on the command that deals with "timeminute" and not *every* other line in the above example.

If this was just a "one off" command (ie you only deal with one hour and that was it),then your example is fine. But as you are doing it 24 times... (or even 12 times), makes more sense to break it down to smaller parts.

Mike308

  • Newbie
  • *
  • Posts: 48
Re: Building a complex Conditional Statement
« Reply #3 on: November 09, 2017, 09:29:55 PM »
Great guidance gang, thank you very much!!  Off to tinker a bit, excited to see what comes of it!!

Pfeil, my original question was if there was a way to copy/paste my entire block of conditions (all lines) in one fell swoop but watching some vids and reading the manual, I can see that I need to drop in each line as an element and build the full list rather than treat it as a wall-o-text.

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4785
  • RTFM
Re: Building a complex Conditional Statement
« Reply #4 on: November 10, 2017, 07:15:39 AM »
my original question was if there was a way to copy/paste my entire block of conditions (all lines) in one fell swoop but watching some vids and reading the manual, I can see that I need to drop in each line as an element and build the full list rather than treat it as a wall-o-text.

Copy/paste from where? Do you have everything typed up in another application already and are looking to put that into VoiceAttack directly?
That is indeed not possible.


I inferred you wanted to save yourself the hassle of manually creating each action individually by doing something like this:



I'm using duplicate here, but copy/paste would have the same effect.

You can also increase the amount of items you duplicate exponentially as you create more actions, E.G. duplicate the first 3 conditional branches, then select the 6 you now have in total and duplicate those, then select the 12 you have and duplicate those again, and so on.



Mike308

  • Newbie
  • *
  • Posts: 48
Re: Building a complex Conditional Statement
« Reply #5 on: November 25, 2017, 07:45:49 PM »
The examples were  a) amazing and b) immensely helpful. Everything is done now and working beautifully. It was a big learning step and opened a whole bunch of other options. Many thanks!!