Action that take any string as argument?

Hi all,

I am very new to IF development (started yesterday), and I am trying to make an IF that involves some word puzzles. So I’d like to be able to define an action like “answer XXX”, where “XXX” can be any string that is to be validated. I looked at a couple TADS tutorials, but it seems like the actions all expect the name of an object. Is there a way to get around this, where I can let the user enter any arbitrary string as input? Thanks to all in advance, your help’s greatly appreciated!

Sure. There’s an article on creating verbs in the TADS 3 Technical Manual. Scroll down to the section “Verbs with a “literal” object”, which explains how to create verbs that take a string of text instead of an object. You might also want to read the section “Verbs with no objects”, since these two kinds of verbs are very similar.

If you still have questions after reading that article, just ask!

Super! That worked perfectly, thank you so much!!! :smiley:

Actually I do have a second question now, so I’ve made my action that takes a single literal, now if the user types just “answer” without any parameter, I get “invalid index operation”. I guess the code wasn’t smart enough to handle the empty string case, or something like that. So what should I do? Try catch? Make yet another action Answer that takes no argument at all? (ideally i just want to print “what do you want to answer”)

Thanks again for any help!

Using the example code in the Technical Manual, I don’t get that problem. If I enter “say” on its own, it asks me what I want to say, as it should. Can you post your code?

Ahhhhh I see! I did not define my verbPhrase correctly. Now I finally know what this parameter is used for! Thanks again :slight_smile: