VoxCommando Forum

Help and Support (Using VoxCommando) => VoxCommando Basics and Core Features => Topic started by: Mirac78 on June 29, 2014, 09:40:28 AM

Title: Need help with logic
Post by: Mirac78 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
Title: Re: Need help with logic
Post by: nime5ter 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.

<?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).

<?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>

Title: Re: Need help with logic
Post by: Mirac78 on June 29, 2014, 02:06:49 PM
TNX nime5ter, using first option and it's work great!

M.
Title: Re: Need help with logic
Post by: jitterjames on June 29, 2014, 02:36:37 PM
For what it's worth I think the third option makes the most sense.