News:

There is now a ChangeLog page on the wiki
New developments are added at the bottom of the page.

Main Menu

arithmatic operation inside commands

Started by Haddood, October 19, 2016, 01:49:12 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Haddood

James,

since it has been very long time since my last feature request :8 .. I was wondering if is it feasible to provide some simple arithmetic operations within the commands just like we could use maps and variables... i.e. say we can

if A<B , {arth. 3 + 5/2} , {arth.{var.a} + 5 * {var.b}}

support for basic function + - * / will be ample start

this will be awesome simplify lots of commands

P.S. it will be great xmas gift for all voxteers !!!
When Voice command gets tough, use hand gestures

Kalle

Hi Haddood,


so far I know is this already possible with the python plugin in VoxCommando.  ::hmm


http://voxcommando.com/mediawiki/index.php?title=Python#Returning_a_Result
***********  get excited and make things  **********

nime5ter

#2
Based on your example, I think you mean that you want to be able do calculations within individual parameters in an action, as opposed to within a command.

James says he may implement your suggestion in the future for user convenience. In the meantime, you can do this now using one line of Python within a command (PY.ExecString).

Per your example:

<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.2.2.7-->
<command id="66" name="evaluate my arithmetic in this command" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>Results.SetVar</cmdType>
    <params>
      <param>a</param>
      <param>{1}</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Results.SetVar</cmdType>
    <params>
      <param>b</param>
      <param>{2}</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>PY.ExecString</cmdType>
    <params>
      <param>result =  (3 + 5.0/2) &lt;  ({var.a} + 5.0*{var.b})</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <if ifBlockDisabled="False" ifNot="False">
    <ifType>(A)==(B)</ifType>
    <ifParams>{LastResult}&amp;&amp;True</ifParams>
    <then>
      <action>
        <cmdType>OSD.ShowText</cmdType>
        <params>
          <param>Last result is: {LastResult}</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
    </then>
    <else>
      <action>
        <cmdType>OSD.ShowText</cmdType>
        <params>
          <param>Last result is: {LastResult}</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
    </else>
  </if>
  <phrase>test your own var values as payloads</phrase>
</command>


You can test different {var.a} and {var.b} values by entering different numbers in the test fields for payload 1 and 2 in the LCB.
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

Haddood

Quote from: nime5ter on October 19, 2016, 08:38:36 AM
do calculations within individual parameters in an action, as opposed to within a command.

this is exactly what I meant :D ... kind of arithmetic on the fly as opposed to create commands to get the results in variables
When Voice command gets tough, use hand gestures

nime5ter

:) Your idea will probably be helpful to many.

But we don't currently have to create separate commands. Often we can just do the arithmetic using a single Python action within our command. (At least, I haven't personally run into a scenario involving basic calculations that required creating a separate command.)
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)