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"):
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:
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()".