[I6] Parsing various stuff

Sorry for this newbie question, but despite consulting the manual and various example files, I don’t understand how to parse stuff. Input is “type xxx”, and after various tries I’m clueless on how to do it. I’m catching “type” via Verb, but whatever I try, either NextWord() gives back a number, or I receive “I only understood you as far as you want to type”. What do I have to do if I have a verb and want to know what text was typed after it?

Have you looked at Chapter 31 of the DM4? The player’s input text will be matched by the topic token.

Sorry, but I don’t get it.

[ TypeSub t;
		"You typed ",t,".";

Verb 'type' * topic -> Type;

“type test” results in “You typed 0.”, so NextWord() seems to return an rfalse. Why? How do I correctly parse this?

First off, there are some errors in your code. You have to change “t == NextWord()” to “t = NextWord()”. Also, in the next line you have to put “(address) t” rather than just “t”.

However, you are not home free because NextWord() does not behave the way you want it to (or that, probably most people would expect). If the word it finds is in the game’s dictionary then it returns that word. If the word it finds is not in the game’s dictionary then it returns 0. So attempting to directly print the output of NextWord() will often fail. Also, when you work with NextWord() you have to be sure of the location of the word marker, which is set by the global variable wn.

However, there is a very limited way to get it to do what you want, basically by adding words to the dictionary.

[code][ TypeSub wd;

wn = consult_from;
wd = NextWord();
if (wd == ‘hello’) ;
"You typed ", (address) wd, “.”;

The addition of the third line causes it to work correctly when wd is either a recognized dictionary word or the word “hello”. If it is anything else it will produce garbage. If you don’t include that line it will print garbage even when wd is a recognized dictionary word.

Also, that will only work for the first word typed. The player could type as many words as she likes.

Cool, works! Thanks for the help!