Author Topic: Variable looping  (Read 2825 times)

0 Members and 1 Guest are viewing this topic.

OklahomaGreyBeard

  • Contributor
  • ***
  • Posts: 54
  • Karma: 3
    • View Profile
Variable looping
« on: May 11, 2015, 11:51:56 AM »
I've tried playing with the add loop function in CB and I don't know if I'm not understanding it, or if I'm using it for the wrong thing.  What I need is in my home cooling RoboB session, it can tell me what the current setting is. What I'd like to be able to do is say "set the room temperature to 72" it then looks to see it's currently at 80, does the math and clicks the down button 8 times then clicks submit. I can do everything including figuring out how many times to click the button (and the correct button depending on if it needs to go up or down) but it's setting the amount of time it clicks I can't seem to get.

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Variable looping
« Reply #1 on: May 11, 2015, 12:09:40 PM »
The method to use for this will depend on your whole command structure, so it would be easier to help if we could see your command xml (almost always true, btw).

But here is a generic example of how the loop block works:

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.1.4.6-->
<command id="678" name="Loop demo" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>Results.SetLastResult</cmdType>
    <params>
      <param>{Rnd.1.10}</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>OSD.ShowText</cmdType>
    <params>
      <param>I will now loop {LastResult} times:</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <loop>
    <loopParams>
      <from>1</from>
      <to>{LastResult}</to>
    </loopParams>
    <loopActions>
      <action>
        <cmdType>OSD.AddText</cmdType>
        <params>
          <param>{j}. hi</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
    </loopActions>
  </loop>
  <phrase>Loop demo</phrase>
</command>
« Last Edit: June 16, 2016, 02:44:49 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)

OklahomaGreyBeard

  • Contributor
  • ***
  • Posts: 54
  • Karma: 3
    • View Profile
Re: Variable looping
« Reply #2 on: May 11, 2015, 12:27:46 PM »
Absolutely perfect. I did not know that you could use a variable in the Loop Over Range action. (checked the WIKI and it says coming soon  :D )

Once I have this all down, I plan on posting the command set so others that may have this same Honeywell thermostat cloud issue can insert their own login and password and control it. My only remaining issue now is the login timeout problem in the other thread.

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Variable looping
« Reply #3 on: May 19, 2015, 11:58:07 AM »
Absolutely perfect. I did not know that you could use a variable in the Loop Over Range action. (checked the WIKI and it says coming soon  :D )


Thanks for mentioning the missing documentation. This has now been addressed.

http://voxcommando.com/mediawiki/index.php?title=Logical_Command_Builder

links to:

http://voxcommando.com/mediawiki/index.php?title=Add_Loop

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)