Author Topic: Please help with Boolean Var  (Read 8119 times)

HansNel

  • Guest
Please help with Boolean Var
« on: June 29, 2018, 04:02:13 AM »
Hi guys, I hope you can help me with this problem...
I don't know how to fill a variable by voice eg:

TTS Voice is "Justin"
______________________________________

rest = False
[Me] "Justin, are you capable to restart my PC"?
[Justin] "Yes sir, would you like me to do that"?

If ????? (my spoken response) = "yes" then rest=True ELSE rest=False
If rest = True then Restart PC ELSE Exit Command

????????????????????
________________________________________

My problem is that I use "yes" and "no" many times so I cannot "hardwire" my response in this block.
How exactly does VA "hear" my response so I can load variables...and not only by key/mouse presses?

Thanks guys
Keep well

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4759
  • RTFM
Re: Please help with Boolean Var
« Reply #1 on: June 29, 2018, 05:00:35 AM »
If you're running beta v1.7.0.12 or higher, you can use the "Wait For Spoken Response" action:

Code: [Select]
Wait for spoken response: 'yes;no'
Begin Text Compare : [rest] Equals 'yes'
    Restart PC
End Condition

I'd just use the text variable output directly; Unless you're doing something else with the value later on, there's no reason to involve a boolean variable.

HansNel

  • Guest
Re: Please help with Boolean Var
« Reply #2 on: June 29, 2018, 10:28:20 AM »
Thank you Pfeil! I truly appreciate it!

Is there a tutorial that teaches the principles of VA Script. I am a MS Visual Basic programmer so I should master this quite soon.

So, "Wait for spoken response" is the "method" to get a "string" from the user. I suppose if the user say "one" and I need to perform a calculation, I will have to convert the "string" variable to an Integer or Boolean, whatever?

Thanks again
Hans :-)

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4759
  • RTFM
Re: Please help with Boolean Var
« Reply #3 on: June 29, 2018, 12:26:18 PM »
Is there a tutorial that teaches the principles of VA Script. I am a MS Visual Basic programmer so I should master this quite soon.
There is documentation, in the form of VoiceAttackHelp.pdf, which is located in the installation directory and can be opened quickly by pressing F1 while VoiceAttack has focus.


So, "Wait for spoken response" is the "method" to get a "string" from the user. I suppose if the user say "one" and I need to perform a calculation, I will have to convert the "string" variable to an Integer or Boolean, whatever?
Actions in VoiceAttack could be considered methods, but they don't actually return anything directly.
Instead, they create a variable that's immediately accessible by all elements within the scope of that variable.

Tokens are actually closer to a method, in the way they're generally used. A token will always be replaced with text representing its output, without using a variable.
E.G. "{EXP: 1 + 1}" would be replaced with "2".

You can manually convert a value from one type to another, however, if it's already in a form that can be converted to the target type you may not need to; Anywhere a token is accepted, its output will be converted to whatever internal type is required(if possible).


In your example, you could have "1" as the literal phrase, which can then be used in an action through a token, without using intermediate variables(or logic, as would be required to get 1 from "one"):
Code: [Select]
Wait for spoken response: '1;2'
Write [Purple] '{EXP: {TXT:output} + 1}' to log
Depending on the spoken phrase, the output would be "2", "3", or "Expression error"(if the spoken response times out, in which case you can't add the string "Not Set" to the integer 1).

The "{EXP:}" token can be quite useful, however it can also quickly become difficult to read and maintain if used for more complex operations(in the same way any one-liner does).


You can also use the "Compute against a variable or token" option of the "Set an Integer Value" action(other datatypes use their respective action) to do math:
Code: [Select]
Set integer [test] value to 1
Wait for spoken response: '1;2'
Set integer [test] to [test] plus [{TXT:output}]
Write [Purple] '{INT:test}' to log
The output should be the same as the previous example, except when the response times out(you'll get a "Integer token / text could not be converted : {TXT:output}" message, and the "Write a Value to the Event Log" action will print "1", because that's the value "test" was set to).

In this case, the "{INT:}" token is used as the equivalent of "ToString()".

Exergist

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 405
  • Ride the lightning
Re: Please help with Boolean Var
« Reply #4 on: June 29, 2018, 03:36:31 PM »
The manual looks long and scary (well, not TOO scary), but there's a wealth of useful information and examples. Gary also adds his humor throughout :)

HansNel

  • Guest
Re: Please help with Boolean Var
« Reply #5 on: July 04, 2018, 12:28:17 PM »
Thank you a lot, my friends. This is quite different than Visual Basic, but I will absolutely get then hang of it.
All I need to know, for now, is how to get a spoken response from the user into a variable. Mainly for "choices"...ie:

IF ....THEN

ELSE

ENDIF

I understand it was not needed to use the boolean routine before I actually posted on this forum. At that time I needed a "Yes"/"No" action and the boolean it great at this for it is a Yes/No; True/False routine. But, yes, not in this choice.

This must be ancient to you guys, but I started on the ZX-81 through VB2014 (I think :-) )

I must also find a way for VA to select a menu or submenu and
move the mouse to a point on the screen and fire a click event by the voice of the user...say to click on a CommansButton etc.

WOW! I've got lots learn, and I understand I am dealing with a master here, Pfeil. I was told by VA people that you a the genius regarding this subject, so your reputation is preceding you! It's an honour!

Best regards
Hans


Exergist

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 405
  • Ride the lightning
Re: Please help with Boolean Var
« Reply #6 on: July 05, 2018, 10:45:14 AM »
Quote
All I need to know, for now, is how to get a spoken response from the user into a variable. Mainly for "choices"...ie:

IF ....THEN

ELSE

ENDIF
Gary provided an excellent post about the Confirmation and Basic Response functionality. Give that a look and it should give you guidance about your question.

Quote
I must also find a way for VA to select a menu or submenu and
move the mouse to a point on the screen and fire a click event by the voice of the user
You can use the Mouse 'Move' and 'Click' actions to achieve these. You will have to figure out the (X,Y) pixel coordinates for positioning your mouse. You can use this simple command to get the coordinates under your mouse:
Code: [Select]
Write [Blue] '(X,Y) = ({MOUSESCREENX},{MOUSESCREENY})' to log