Author Topic: Map.Query to get the first row of a map table  (Read 1508 times)

0 Members and 1 Guest are viewing this topic.

PegLegTV

  • $upporter
  • Sr. Member
  • *****
  • Posts: 497
  • Karma: 43
    • View Profile
Map.Query to get the first row of a map table
« on: May 21, 2018, 03:58:17 PM »
is it possible to use Map.query to get the 1st row (top item) in a map table. SQL is not something I know much if anything about and I can't seem to find a way to get the first row of a map table,  :bonk

If that's not possible, is it possible to get all fromkey's listed in a map table?

I'm working on a command using YouTube-dl and I'm trying to create a queue and need to check it when Youtube-dl completes its task. I don't know exactly what the fromkey is going to be so I can't check them individually.

Thanks

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Map.Query to get the first row of a map table
« Reply #1 on: May 21, 2018, 04:42:35 PM »
We should probably update the action description to provide more examples. Sorry about that.

The map is actually an SQLite table, so if you look online for SQLite documentation it should help (in combo with my response here).

Here are 3 different commands to give you an idea of things you can do with the Map.Query action.

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.2.3.8-->
<commandGroup open="True" name="Sample sqLite queries for Map Tables" enabled="True" prefix="" priority="0" requiredProcess="" description="">
  <command id="280" name="Select * from Map Table" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="Each map row is a returned as a match.">
    <action>
      <cmdType>Map.Query</cmdType>
      <params>
        <param>Select * from YourTableName</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>OSD.ShowText</cmdType>
      <params>
        <param>fromKey --&gt; toValue</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>OSD.AddText</cmdType>
      <params>
        <param>{Match.{i}.1} --&gt; {Match.{i}.2}</param>
      </params>
      <cmdRepeat>{#M}</cmdRepeat>
    </action>
  </command>
  <command id="268" name="Get all Keys in Map Table" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="If you want all values, Select toValue from YourTableName.">
    <action>
      <cmdType>Map.Query</cmdType>
      <params>
        <param>Select fromKEY from YourTableName</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>OSD.AddText</cmdType>
      <params>
        <param>{Match.{i}}</param>
      </params>
      <cmdRepeat>{#M}</cmdRepeat>
    </action>
    <phrase>Get all Keys in Map Table</phrase>
  </command>
  <command id="278" name="Limit Map query to first row" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="You can set the limit to whatever. Limit 3 would return top 3 rows. etc. Of course, you can also just use Match.1 without setting a limit in your query, but in that case the query is still returning all matches.">
    <action>
      <cmdType>Map.Query</cmdType>
      <params>
        <param>Select * from YourTableName LIMIT 1</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>OSD.ShowText</cmdType>
      <params>
        <param>{Match.1}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>OSD.AddText</cmdType>
      <params>
        <param>{Match.1.1} : {Match.1.2}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>Limit Map query to first row</phrase>
  </command>
</commandGroup>

If you have follow-up questions let me know. ... Or James may post more info later when he has time.

[Edit: Updated xml for clarity]
« Last Edit: May 25, 2018, 07:56:55 AM 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)

PegLegTV

  • $upporter
  • Sr. Member
  • *****
  • Posts: 497
  • Karma: 43
    • View Profile
Re: Map.Query to get the first row of a map table
« Reply #2 on: May 21, 2018, 04:53:52 PM »
Thank you, I'll check them out when I'm back at home

PegLegTV

  • $upporter
  • Sr. Member
  • *****
  • Posts: 497
  • Karma: 43
    • View Profile
Re: Map.Query to get the first row of a map table
« Reply #3 on: May 21, 2018, 05:51:47 PM »
These actions will come in handy, Thank You very much  :D