Author Topic: Status variable gives the previous status 2  (Read 1002 times)

0 Members and 1 Guest are viewing this topic.

Haddood

  • $upporter
  • Hero Member
  • *****
  • Posts: 688
  • Karma: 22
    • View Profile
Status variable gives the previous status 2
« on: March 19, 2015, 03:11:39 PM »
in version 2.142 it seems the status variable is listing the previous status

I am testing this command and the LED Colour lists the previous Status ...

(it will be great to have to variables, Status and Previous Status)

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.1.4.2-->
<command id="862" name="LED Control" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <if ifBlockDisabled="False" ifNot="False">
    <ifType>(A)==(B)</ifType>
    <ifParams>{status}&amp;&amp;on</ifParams>
    <then>
      <action>
        <cmdType>PY.ExecString</cmdType>
        <params>
          <param>LEDcolour("Green")</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
    </then>
    <else />
  </if>
  <if ifBlockDisabled="False" ifNot="False">
    <ifType>(A)==(B)</ifType>
    <ifParams>{status}&amp;&amp;off</ifParams>
    <then>
      <action>
        <cmdType>PY.ExecString</cmdType>
        <params>
          <param>LEDcolour("Red")</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
    </then>
    <else />
  </if>
  <if ifBlockDisabled="False" ifNot="False">
    <ifType>(A)==(B)</ifType>
    <ifParams>{status}&amp;&amp;standby</ifParams>
    <then>
      <action>
        <cmdType>PY.ExecString</cmdType>
        <params>
          <param>LEDcolour("Yellow")</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
    </then>
    <else />
  </if>
  <event>VC.On</event>
  <event>VC.Standby</event>
  <event>VC.Off</event>
</command>
When Voice command gets tough, use hand gestures

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7713
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Status variable gives the previous status 2
« Reply #1 on: March 19, 2015, 03:45:29 PM »
This is not specific to version 2.1.4.2

It is not that it is reporting the previous status, it is just that the event triggers immediately before the status variable is updated so in this particular command it is reporting the wrong value.  However quickly things might appear to take place on a computer, they still only happen one thing at a time!

Obviously it would be better if this variable was updated before the event is fired and I will look into that.

In the meantime you can work around it in one of two ways (at least).

1 - Use {LastEvent}
2 - Prefix your command name with a ++ so that it's threaded and then put a very short VC.Pause action at the beginning of your command.

Haddood

  • $upporter
  • Hero Member
  • *****
  • Posts: 688
  • Karma: 22
    • View Profile
Re: Status variable gives the previous status 2
« Reply #2 on: March 20, 2015, 02:49:08 AM »
After a bit of more texting I reached the same conclusion and went with option 1 ... However I will try option 2 ...

Thanks
When Voice command gets tough, use hand gestures