Author Topic: logic commands for existing data in payloads  (Read 2982 times)

0 Members and 2 Guests are viewing this topic.

gavimobile

  • Jr. Member
  • **
  • Posts: 8
  • Karma: 1
    • View Profile
logic commands for existing data in payloads
« on: November 01, 2018, 05:13:22 PM »
excuse me if this is not the right category.
what would be a simple example for checking if a value or phrase exists first within a xml payload.
if it does exist don't add to payload
if it does NOT exist, add to xml payload.
im breaking my head with this for a few days already.

any assistance is appreciated

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7715
  • Karma: 116
    • View Profile
    • VoxCommando
Re: logic commands for existing data in payloads
« Reply #1 on: November 01, 2018, 06:39:27 PM »
There are a few unknowns in your question so I'll have to make some assumptions to answer this.

First assumption: You are talking about adding rows to a payloadXML file using actions of the form payloadXML.*

Second assumption: Check if a value exists.  Checking for a phrase could be done too but slightly differrently and it could be more complicated because of the possibility of multiple comma separated phrases for a single value.

Basically you can use PayloadXML.GetPhrase to check if a value already exists.  Then in a logic block use LastActionSuccess.  If true then you don't need to add it because it's already there.  Else add the new value/phrase pair.

Very simple example:


Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.2.4.3-->
<command id="1224" name="payloadxml tests" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>PayloadXML.GetPhrase</cmdType>
    <params>
      <param>test.xml</param>
      <param>2</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <if ifBlockDisabled="False" ifNot="False">
    <ifType>LastActionSuccess</ifType>
    <ifParams>&amp;&amp;</ifParams>
    <then>
      <action>
        <cmdType>VcAdvanced.Log</cmdType>
        <params>
          <param>value already exists in payloadXML file</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
    </then>
    <else>
      <action>
        <cmdType>PayloadXML.AddPair</cmdType>
        <params>
          <param>test.xml</param>
          <param>2</param>
          <param>two</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
    </else>
  </if>
</command>

gavimobile

  • Jr. Member
  • **
  • Posts: 8
  • Karma: 1
    • View Profile
Re: logic commands for existing data in payloads
« Reply #2 on: November 04, 2018, 03:38:03 PM »
thanks, this was exactly what I needed.