Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Candall on Mon 26/11/2007 02:09:17

Title: Period/Fullstop in Text Parser? (SOLVED)
Post by: Candall on Mon 26/11/2007 02:09:17
I've been attempting to implement a function in which my player character can inquire about a computer file (complete with extension) by way of the text parser.

When I enter the word in the parser list as "filename.ext" I get problems.  The code works perfectly if I simply use "filename".

I'm certain that I'm updating both the parser list and the calling function.

So is the problem that periods can't be used as regular characters in the text parser?  If so, is there a known workaround?
Title: Re: Period/Fullstop in Text Parser?
Post by: frission on Mon 26/11/2007 04:15:48
The easiest workaround would be to just turn the periods into something else before running ParseText, e.g.

while (inputText.Contains(".")!=-1) {
    inputText.ReplaceCharAt(inputText.Contains("."),"_");
}
Parser.ParserText(inputText);

And then just make sure that instead of "filename.ext", your parser list contains names like "filename_ext" or whatever. (And if "_" doesn't work for some reason, change it to something else).
Title: Re: Period/Fullstop in Text Parser?
Post by: Khris on Mon 26/11/2007 06:10:35
ReplaceCharAt has to be called with a char as second parameter, so use '_' instead.
Title: Re: Period/Fullstop in Text Parser?
Post by: Candall on Mon 26/11/2007 07:07:47
Thanks!  It worked beautifully after a couple of minor repairs, one of which KhrisMUC pointed out.  Here's the code I ended up using after consulting the manual on the great direction in which you pointed me:

while (ech.Contains(".")!=-1){
ech=ech.ReplaceCharAt(ech.Contains("."), '-');
}


As said, that works perfectly.  I posted it for the benefit of anyone who may run into this problem in the future.

Edit to add:  It turns out that the only "special" character I could find that didn't cause problems was a hyphen, though it really didn't matter whether the character was special or not so long as the altered string matched what was in the parser list.