Author Topic: Help with an Action  (Read 3460 times)

0 Members and 2 Guests are viewing this topic.

DHHJ

  • $upporter
  • Contributor
  • *****
  • Posts: 62
  • Karma: 1
    • View Profile
Help with an Action
« on: August 24, 2014, 08:10:42 PM »
Can I get a simple few lines showing the correct syntax for GetValue. I tried:

Code: [Select]
from System.Collections.Generic import *
vc.callAction("c:\\voxcommando\\vc2_008\\payloads","Supertramp",false)

but am getting a expected List[str], got boolean error? Thx.

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Help with an Action
« Reply #1 on: August 24, 2014, 09:14:03 PM »
Let us know what you are trying to do and maybe we can help.

For starters why are you using python instead of a regular command macro with actions in VC?

If you want to call VC actions from python, you should look at this page which includes a simple example.

http://voxcommando.com/mediawiki/index.php?title=Python#Actions

DHHJ

  • $upporter
  • Contributor
  • *****
  • Posts: 62
  • Karma: 1
    • View Profile
Re: Help with an Action
« Reply #2 on: August 25, 2014, 11:38:35 AM »
Sorry, I was trying to be brief- just looking for some syntax help (example code) with the Python wiki entry for GetValue as I am just playing with Python as a noob.

I am looking at using a phrase to get values in multiple xml files. For example, if I had a Name and had diffferent xml files with info about Name, like

Name's phone number?
Name's favourite sport?
Name's shoe size?
Name's birthday?
etc.

I'd like to do something like
vc.callAction("c:\\voxcommando\\vc2_008\\payloads\\shoesize.xml","Joe Blow",false)to get their shoe size and
vc.callAction("c:\\voxcommando\\vc2_008\\payloads\\sport.xml","Joe Blow",false) to get their favourite sport

Thx

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Help with an Action
« Reply #3 on: August 25, 2014, 01:17:03 PM »
You'll need to make sure to copy the syntax exactly as written in the documentation rather than replacing the syntax with your own, so:

1. Provide the name of the action you want to use, or python won't know which VC action you're trying to call.
.
2. If the VC action that you want to use takes more than one parameter value, you'll need to separate these with "&&" in your python syntax. Note also that you can use relative file paths, if the files are in the same directory as the instance of VC you are running (e.g. "payloads\shoesize.xml").

3. As you can see, the final parameter in the callAction method is not "False" but "None". Fixing this should resolve the current error you're getting.

« Last Edit: August 25, 2014, 01:29:42 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)

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Help with an Action
« Reply #4 on: August 25, 2014, 01:32:32 PM »
Also your paths should be using a single backslash, not doubles.

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Help with an Action
« Reply #5 on: August 25, 2014, 06:37:42 PM »
Not to discourage anyone from playing with python, but if the aim is to have one command that can query multiple payload xml files at once, asking for just one piece of information at a time (e.g. "What's Joe Blow's shoe size?", "What's Joan of Arc's favourite sport?"), it may be easier to stick with a VC-only solution such as:

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.0.0.8-->
<command id="331" name="Get profile info" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>PayloadXML.GetValue</cmdType>
    <params>
      <param>{2}</param>
      <param>{1}</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <if ifBlockDisabled="False" ifNot="True">
    <ifType>LastActionSuccess</ifType>
    <ifParams>&amp;&amp;</ifParams>
    <then>
      <action>
        <cmdType>OSD.ShowText</cmdType>
        <params>
          <param>I'm sorry, that information is not available.</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
      <action>
        <cmdType>TTS.Speak</cmdType>
        <params>
          <param>I'm sorry, that information is not available.</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
    </then>
    <else>
      <action>
        <cmdType>OSD.ShowText</cmdType>
        <params>
          <param>The information I have says: {LastResult}</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
      <action>
        <cmdType>TTS.Speak</cmdType>
        <params>
          <param>The info I have says: {LastResult}.|According to your records, {LastResult}.</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
    </else>
  </if>
  <phrase>What, Who</phrase>
  <phrase>is, are</phrase>
  <payloadFromXML phraseOnly="True" use2partPhrase="False" phraseConnector="by" Phrase2wildcard="anyone" optional="False">payloads\contacts.xml</payloadFromXML>
  <payloadFromXML phraseOnly="False" use2partPhrase="False" phraseConnector="by" Phrase2wildcard="anyone" optional="False">payloads\xml_filepaths.xml</payloadFromXML>
</command>

The above requires 2 payload xml files -- one with your contact names, the other one has the file paths for each payload xml file of interest. I've attached an example of the latter, which I hope will clarify what I mean.

This is akin to the method you described wanting to use in python.
« Last Edit: August 25, 2014, 06:40:21 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)