Author Topic: If A contains B (options)  (Read 2200 times)

0 Members and 1 Guest are viewing this topic.

jb5349

  • Jr. Member
  • **
  • Posts: 46
  • Karma: 2
    • View Profile
If A contains B (options)
« on: November 16, 2013, 10:41:39 AM »
I'm not sure if this is entirely possible or not or if there is a method for this but, can the B in an If  A contains B have a list of things to match?

Following the same logic of using phrases, it would look something like this...


If {LastResult} contains "option1, option2, option3" then

Perform action(s)

Else


Ok so real world example....

If weather conditions contains "rain, thunderstorm,  drizzle" then

tts.speak " it's raining | looks like rain | it's currently raining"


Now second part of this question, if we can't list the items like option1, option2, etc. to match against , a payload XML be defined in the B field to check against? So instead of just a few options maybe I have a long list of them?

Anyway, wondering if this could be done?

From a programming side, looks like if condition A string contains B string then is the way it appears to work now. With my example, it would follow along something lines of...

Check B string for delimiter ","  (if it exists then parse the items then run through a For loop until each B string is compared to A string for a match) and if any are a match then do Actions
Else do standard match of A contains B and if there is a match do Actions

Anyway, hope this can be done as it would sure save having to create so many If then logic items for similar words I want to match.

Thanks!

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: If A contains B (options)
« Reply #1 on: November 16, 2013, 11:39:16 AM »
Sure, just use the Python plugin.
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: If A contains B (options)
« Reply #2 on: November 16, 2013, 12:21:01 PM »
Ok so real world example....

If weather conditions contains...

Anyway, wondering if this could be done?

This can be done but you are using contains the wrong way (backwards).  Imagine that you have stored the weather conditions in LastResult.  To see if it matches one of several conditions you would do  this:

Code: [Select]
If  "rain, thunderstorm,  drizzle" contains {LastResult}
This will return true if {LastResult} is equal to any of the items in the list.  You don't have to use commas, but using some kind of item separator will help to avoid accidental matching depending on the possible values that the weather plugin could return.

It should be pretty easy to understand the order to use with "contains".  "A" must be larger than "B" in order for "A" to contain "B".
*  An elephant might contain a mouse, but it is unlikely that a mouse would contain an elephant.
*  A list of items may contain an item, but a single item will not contain a list of items.

jb5349

  • Jr. Member
  • **
  • Posts: 46
  • Karma: 2
    • View Profile
Re: If A contains B (options)
« Reply #3 on: November 16, 2013, 12:38:38 PM »
Wow, never occurred to me to use it in reverse. Genius!

I wish these amazing abilities were more documented beyond the forum posts. I know  it takes time but I can see a very thorough video training course with lots of real world examples doing wonders for newbies to VC like myself. Even if the wiki had these written out and maybe embedded video clips (for those of us that learn by seeing and doing). Hey you can call it VoxCommando Bootcamp.  ;)

I don't know what your long term goals for VC are but I can see so much potential with this tool. I think most users don't understand the power that lies within and seeing some real world examples of how or actually do it would be a great introduction and possibly increase the user base.

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: If A contains B (options)
« Reply #4 on: November 16, 2013, 01:00:14 PM »
In addition to the forum, there is a very large wiki and there are many youtube video tutorials.

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: If A contains B (options)
« Reply #5 on: November 16, 2013, 01:08:03 PM »
Wow, never occurred to me to use it in reverse.

Actually it did.  It never occurred to you to use it NOT in reverse.  :biglaugh

jb5349

  • Jr. Member
  • **
  • Posts: 46
  • Karma: 2
    • View Profile
Re: If A contains B (options)
« Reply #6 on: November 16, 2013, 01:40:55 PM »
Ok you are correct. I never saw an example where it was used properly to begin with so I assumed If this then that logic and applied it. I guess I forgot that this is more of a matching logic like what a select case would offer.

Either way it's awesome.