Parser Question

Started by , Mon 14/07/2003 04:11:02

Previous topic - Next topic

KilltheSand

How can I reoutput the first word of what was typed?
Example

If (Said ("Word rol"))
 Display ("%w", Word);

It is not an unknown word.  I have many synonyms and I want it to display the one that was entered.

Thank you in advance,
Steve O.

Wolfgang Abenteuer

#1
That's a tough one, because whatever is typed into and processed by the parser is written into the string, so even if you have it set up to display that string then it will display the whole thing (including whatever was typed after "Word").

My best guess would be to separate all of the words out into different Said() lines and change a certain string accordingly.  Kind of like this:

string word;

if (Said("money rol")) {
StrCopy(word, "money");
}
else if (Said("cash rol")) {
StrCopy(word, "cash");
}
else if (Said("pounds rol")) {
StrCopy(word, "pounds");
}
else if (Said("bucks rol")) {
StrCopy(word, "bucks");
}
Display ("%s", word);
}

It might be kind of a pain that way but it should work.  Just be sure that the name of the second string is different than the name of the string you're using for your GetTextBoxText() function.

Edit: Also you may need to de-synonym them in the parser list because once it sees the first word it'll try to find a synonym for it and if it's a valid synonym it won't continue on with the next part of the code, but I'm not positive about that.

~Wolfgang

KilltheSand

I REALLY don't want to do that with 34 synonyms!  I can live without it but it would be nice.

Pumaman

Rather than using the parser, you could extract the first word from the string using the StrGetCharAt function. If you need more help on how to do it exactly, feel free to ask.

SMF spam blocked by CleanTalk