VoxCommando Forum

Help and Support (Using VoxCommando) => VoxCommando Basics and Core Features => Topic started by: jb5349 on September 27, 2014, 11:45:36 AM

Title: How to handle when no map entries found?
Post by: jb5349 on September 27, 2014, 11:45:36 AM
So I have a map setup with favorites and with relationships. I can have VC store a new entry such as  color and blue with color being key and blue being the value.

However, my issue is not with creating new keys/values or looking up existing ones, but with how to handle when no key/value exists yet.

For example, I ask, what is my favorite food. VC checks for the key food and it doesn't exist yet, so I want it to return, "I don't know, perhaps you can teach me that"

I tried using {EMPTY} but that did not work.

Any ideas? Thanks!
Title: Re: How to handle when no map entries found?
Post by: jitterjames on September 27, 2014, 11:58:33 AM
Yes you can do the following:

- Use the Map.Get action
- Followed by a logic block that checks LastActionSuccess.

put "I don't know, perhaps you can teach me that"  in the else actions
Title: Re: How to handle when no map entries found?
Post by: jb5349 on September 27, 2014, 12:23:27 PM
Awesome thanks! I just couldn't figure out how to go about it! That helps a lot!
Title: Re: How to handle when no map entries found?
Post by: jb5349 on September 27, 2014, 12:45:15 PM
Just to add to that, you also need VC.StopMacro after that so it doesn't go ahead and try to give the normal response and ends the Macro.

So I have it working like this..

If var.CUser = Jeff then

Map.Get JeffsFavs {1}

This checks to see who is talking, and gets the correct list of favorites (Map). {1} is the result of the list of options I provided in the command. (i.e. color, song, food, etc.)

If Last Action Success

Else

TTS.Speak "I don't know"

VC.Stop Macro

Then below that I have the normal response if all else works. I could probably put this in LastActionSuccess as well and not use the stop macro. So it works either way, but at least with the way I have it I can disable the checking for nothing if I had to.

TTS.Speak "Your favorite {1} is {LastResult}
Title: Re: How to handle when no map entries found?
Post by: jitterjames on September 27, 2014, 01:26:58 PM
Quote from: jb5349 on September 27, 2014, 12:45:15 PM
Just to add to that, you also need VC.StopMacro after that so it doesn't go ahead and try to give the normal response and ends the Macro.

Yes, but you only need to do this if you have other actions after the logic block.  If you put all your other actions into the "then" portion of the logic block, then you don't need to use stopMacro.  It depends on how you write your command macro.