Author Topic: Repeat a loop based on suffix number in command?  (Read 911 times)

Sokonomi

  • Guest
Repeat a loop based on suffix number in command?
« on: January 03, 2020, 03:56:18 AM »
Hi all,

How do I get a command to repeat a sequence X amount of times, when the command is "do this X times"?

I need to run a for-loop and capture its range from the command, but I'm kinda lost on how to do that. Can somebody please explain (very specific) how to enter this into the sequence?

Thanks,
- Soko

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Repeat a loop based on suffix number in command?
« Reply #1 on: January 03, 2020, 03:59:38 AM »
Not sure what you mean by "suffix" in this context, but looping based on a number in the spoken phrase can be done like this:
Code: [Select]
Start Loop : Repeat [{TXTNUM:"{CMD}"}] Times
End Loop

Sokonomi

  • Guest
Re: Repeat a loop based on suffix number in command?
« Reply #2 on: January 03, 2020, 05:06:23 AM »
I saw that bit of code before when I was searching the forums and I tried it, sadly it didn't work, so i'm likely doing something wrong. I'm guessing those variables have to be cast somewhere first, but I have no clue how. Hence why I was requesting the answer to be very specific. ;)

This is what i've got;

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Repeat a loop based on suffix number in command?
« Reply #3 on: January 03, 2020, 05:07:30 AM »
Look again at what you have vs what was posted.

Sokonomi

  • Guest
Re: Repeat a loop based on suffix number in command?
« Reply #4 on: January 03, 2020, 05:13:56 AM »
I've removed those excess brackets if that's what you mean, but still doesnt function im afraid.


Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Repeat a loop based on suffix number in command?
« Reply #5 on: January 03, 2020, 05:16:01 AM »
..."price" is not and does not contain any numbers...

Sokonomi

  • Guest
Re: Repeat a loop based on suffix number in command?
« Reply #6 on: January 03, 2020, 05:21:47 AM »
Yes, well, that's the entire point of this problem im having?
I want to give it the number dynamically; Price one, Price two, etc.
If the number would always be the same I could just make it a rigid command.
But that's not what I want, I want to tell it how many times to repeat, via command.

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Repeat a loop based on suffix number in command?
« Reply #7 on: January 03, 2020, 05:37:29 AM »
If you only have a single command phrase like this, that exact phrase is the only thing that can be recognized to trigger your command.

You can define a pre-selected range of numbers, if you know the smallest and largest that will be required, using dynamic command sections.
E.G. "price [1..10]" would allow you to speak "price one" up to "price ten" and have it be recognized.
Specifying the numbers you want to be recognized in this way will allow the speech recognition engine to match what you are saying to the command directly, however it does mean one command can generate a lot of phrases, which is not an issue with ten of them, but as you go higher, the profile load time and memory required will go up as well.

If you want any number to be potentially recognized, you'll have to use wildcards. This means the speech recognition engine will have to guess at what you're trying to say, which is (much) less accurate than the previous method.
E.G. if your command phrase is "price *", the start of your command could look like this:
Code: [Select]
Start Loop : Repeat [{TXTNUM:"{TXTWORDTONUM:"{CMD_AFTER}"}"}] Times

For more information on these subjects, be sure to check the relevant sections of VoiceAttackHelp.pdf (press F1 while VoiceAttack has focus to open it in your default PDF viewer).