News:

HOT TIP! Commands and groups can be copied and pasted directly from your command editor to the forum, and vice versa. This makes sharing command XML on the forum much easier!

Main Menu

Using maps to replace multiple ifs

Started by Haddood, March 27, 2015, 06:58:38 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Haddood

now and then I face a command where I need many ifs (to simulate a switch command) ... and the command does not look efficient ...
today I had this idea to make this very simple. By replace the multiple ifs with values from a map ....
images explain it all ...

for sure for 3 ifs is not a big deal, apart from being neat ... but in case of 50, this will be a big difference

When Voice command gets tough, use hand gestures

nime5ter

That does seem more efficient. :)

Actually in the case of that example, you could even do it in a single line:

<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.1.4.2-->
<command id="587" name="one line" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>PY.ExecString</cmdType>
    <params>
      <param>LEDcolour("{M:Mapping.LED{status}}")</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
</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)

Haddood

Wow ... Now I have to go check all my commands :)
When Voice command gets tough, use hand gestures