Author Topic: Need help with logic  (Read 1459 times)

0 Members and 1 Guest are viewing this topic.

Mirac78

  • Jr. Member
  • **
  • Posts: 49
  • Karma: 5
    • View Profile
    • M.S.Photography
Need help with logic
« on: June 29, 2014, 09:40:28 AM »
I try to make logic with short time to execute some commands if time is higher then 19:00 but can't make it right.

So what i do.. If NOT (A)<(B),  A is {ShortTime} and B is 19:00 then "do my command"

I try with LastResult and always get message in VC "Can't evaluate. Not a number".

Know is the simple thing but i get confused  :o

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Need help with logic
« Reply #1 on: June 29, 2014, 11:28:11 AM »
Unfortunately, the time variables are not interpreted as numbers because of the : in the middle, so you can't directly use < / > logic on them. One option is to use regex.

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 1.9.5.6-->
<command id="269" name="Playing with time" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>Results.RegEx</cmdType>
    <params>
      <param>(\d*):(\d*)</param>
      <param />
      <param>{ShortTime}</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <if ifBlockDisabled="False" ifNot="False">
    <ifType>(A)&lt;(B)</ifType>
    <ifParams>1900&amp;&amp;{Match.1}</ifParams>
    <then>
      <action>
        <cmdType>OSD.ShowText</cmdType>
        <params>
          <param>The time is later than 19:00.</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
    </then>
    <else>
      <action>
        <cmdType>OSD.ShowText</cmdType>
        <params>
          <param>It is still too early.</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
    </else>
  </if>
</command>

Another option would be to use Python.
* Not shown here...

The third option is to use a custom time variable rather than {ShortTime} (http://voxcommando.com/mediawiki/index.php?title=Variables).

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 1.9.5.6-->
<command id="280" name="Playing with time" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <if ifBlockDisabled="False" ifNot="False">
    <ifType>(A)&lt;(B)</ifType>
    <ifParams>1930&amp;&amp;{DtCustom.HHmm}</ifParams>
    <then>
      <action>
        <cmdType>OSD.ShowText</cmdType>
        <params>
          <param>The time is later than 19:30.</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
    </then>
    <else>
      <action>
        <cmdType>OSD.ShowText</cmdType>
        <params>
          <param>It is still too early.</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
    </else>
  </if>
</command>
« Last Edit: June 29, 2014, 12:57:33 PM by nime5ter »
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)

Mirac78

  • Jr. Member
  • **
  • Posts: 49
  • Karma: 5
    • View Profile
    • M.S.Photography
Re: Need help with logic
« Reply #2 on: June 29, 2014, 02:06:49 PM »
TNX nime5ter, using first option and it's work great!

M.

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7712
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Need help with logic
« Reply #3 on: June 29, 2014, 02:36:37 PM »
For what it's worth I think the third option makes the most sense.