Author Topic: Getting INT from CMD not working  (Read 4329 times)

mikelimtw

  • Jr. Member
  • **
  • Posts: 51
Getting INT from CMD not working
« on: February 09, 2017, 01:07:05 AM »
I read this Ex-Issue already and in fact I had the correct command structure, however, I must not be getting the correct double-quotes from my keyboard. I'm using US English as the default language and keyboard in Windows, although I'm using a Traditional Chinese keyboard in Taiwan.

I don't think this should matter as the key layout is identitical to US keyboards, except certain keys have Chinese phonetic characters printed on them - this should not matter as I am using US English locale and keyboard. No matter how many times I re-type the " it's still not working.  :'(

I'm using US Enlgish Windows 10 with VoiceAttack 1.6.1 (release)
« Last Edit: February 09, 2017, 01:10:31 AM by mikelimtw »

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4759
  • RTFM
Re: Getting INT from CMD not working
« Reply #1 on: February 09, 2017, 02:07:28 AM »
The double quote in your post is the correct one(ASCII code 34).

Can you post the actions the problem occurs with?

mikelimtw

  • Jr. Member
  • **
  • Posts: 51
Re: Getting INT from CMD not working
« Reply #2 on: February 09, 2017, 06:06:34 AM »
Hi Pfeil,

I set up a voice command boost interval [5..12] and the following code:

Begin Integer Compare : [BoostDelay] Equals 0
  Say, 'Your auto boost interval is not set. The valid range is from 5 to 12 seconds. To set, say the command boost interval followed by a number from 5 to 12.' (and wait until it completes)
Else
  Set integer [BoostDelay] value to the converted value of {TXTNUM:"{CMD}"} (save value to profile)
  Say, 'Confirmed, auto boost interval set to [BoostDelay] seconds' (and wait until it completes)
End Condition

Everything looks correct, {CMD} does pick up the spoken command. However, [BoostDelay] ends up being Not Set. By the way, what would happen if I didn't include the double-quotes around the {CMD} token? Wouldn't it change the literal "6" into a number?
« Last Edit: February 09, 2017, 06:32:07 AM by mikelimtw »

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4759
  • RTFM
Re: Getting INT from CMD not working
« Reply #3 on: February 09, 2017, 12:37:03 PM »
I set up a voice command boost interval [5..12]
Nothing wrong with the way you're using the token, but realize that as long as "BoostDelay" is either "0" or "Not Set"(provided you have the "Evaluate 'Not Set' as zero" option checked), the first section will always be executed, and the value will never change/be set because that action is never reached.

In addition, there will never be a situation where the user does not input a number, as "boost interval [5..12]" dictates the command must end in a number to be recognized.


what would happen if I didn't include the double-quotes around the {CMD} token? Wouldn't it change the literal "6" into a number?
No, VoiceAttack tokens are independent of any programming language conventions you may be familiar with.
In this case, double quotes tell the parser to use the input directly, rather then look for a text value/variable with the name provided.

mikelimtw

  • Jr. Member
  • **
  • Posts: 51
Re: Getting INT from CMD not working
« Reply #4 on: February 09, 2017, 02:50:05 PM »
I see the logical error now. I need to add a {CMDACTION} and check to see if it evaluates to "Spoken". That should fix the problem where the second part is never executed. Thanks for catching that. I will give it a try and let you know.

EDIT#1: I modified the command as below:

Begin Text Compare : [{CMDACTION}] Does Not Equal 'Spoken'
    Begin Integer Compare : [BoostDelay] Equals 0
        Say, 'Your auto boost interval is not set. The valid range is from 5 to 12 seconds. To set, say the command boost interval followed by a number from 5 to 12.'  (and wait until it completes)
    End Condition
Else
    Set integer [BoostDelay] value to the converted value of {TXTNUM:"{CMD}"} (save value to profile)
    Say, 'Confirmed, auto boost interval set to {INT:[BoostDelay]} seconds'  (and wait until it completes)
End Condition

The problem is that [BoostDelay] still equals Not Set..

« Last Edit: February 09, 2017, 03:03:04 PM by mikelimtw »

mikelimtw

  • Jr. Member
  • **
  • Posts: 51
Re: Getting INT from CMD not working
« Reply #5 on: February 15, 2017, 07:49:48 PM »
Hi Pfeil or Gary, can you please have a look at this? I'm not getting the expected result and I'm not sure why that is. The syntax appears to be correct but the variable still comes up Not Set. I have initialized this variable when my profile starts up. Thanks!

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4759
  • RTFM
Re: Getting INT from CMD not working
« Reply #6 on: February 16, 2017, 02:59:05 AM »
Code: [Select]
Say, 'Confirmed, auto boost interval set to {INT:[BoostDelay]} seconds'  (and wait until it completes)
The problem is that [BoostDelay] still equals Not Set..
Well, yeah, you're speaking a variable named "[BoostDelay]" rather than the one named "BoostDelay", which you've set.

The square brackets in the action list are there to indicate which characters belong to the variable name, they're not actually part of the variable name.

mikelimtw

  • Jr. Member
  • **
  • Posts: 51
Re: Getting INT from CMD not working
« Reply #7 on: February 16, 2017, 12:10:36 PM »
Ok, I feel stupid now. :P

But thanks for catching that... I've looked over it for the past few days and for whatever reason, I just didn't catch that. Thank you again!