Newsgroups: rec.arts.int-fiction
Path: nntp.gmd.de!news.rwth-aachen.de!news.ruhr-uni-bochum.de!news.uni-stuttgart.de!uni-regensburg.de!lrz-muenchen.de!informatik.tu-muenchen.de!Germany.EU.net!EU.net!newsfeed.internetmci.com!ncar!uchinews!kjfair
From: kjfair@midway.uchicago.edu (Kenneth Fair)
Subject: Re: [Inform] Number Nouns - Newbie Question #1
X-Nntp-Posting-Host: ngrh-34.rh.uchicago.edu
X-Kook-Number-2: 14
Message-ID: <kjfair-0804961118390001@uchinews.uchicago.edu>
X-Kook-Code-2: (Grubor+++)*2 Boursy+ Palmer+++++++
Sender: news@midway.uchicago.edu (News Administrator)
Organization: University of Chicago School of Law
X-Newsreader: Yet Another NewsWatcher 2.2.0b6
References: <kjfair-0704962039100001@uchinews.uchicago.edu> <UlO7jH600WB5MAzYZX@andrew.cmu.edu>
Date: Mon, 8 Apr 1996 16:18:38 GMT
Lines: 74

In article <UlO7jH600WB5MAzYZX@andrew.cmu.edu>, "Andrew C. Plotkin"
<erkyrath+@CMU.EDU> wrote:

>kjfair@midway.uchicago.edu (Kenneth Fair) writes:
>> Okay, I'm humming along, building rooms, throwing in a few simple objects,
>> when I run into a small problem.  I have an object whose name is a 
>> number - "90".  [...]
>> No problem.  I can call it "ninety" and all is fine.  But I'd like for the
>> player to be able to type "climb 90" and get the correct response.  Of
>> course, if I put "90" in the name list, Inform rejects it.
>
>Add a parse_name routine.
>
>  parse_name [ num wd;
>    num = 0;
>    wd = NextWord();
>    while ((Refers(self, wd) 
>        || TryNumber(wn-1) == 90) {
>      num++;
>      wd = NextWord();
>    } 
>    return num;
>  ],
>
>This checks all the words in the name property (including inherited
>ones, of course) and also allows the number 90.
>
>Warning: I haven't tested this.

Well, I first got:

   Error: Too many brackets '(' in expression

So I looked closer and thought maybe what you meant was:

   while ( Refers(self, wd) || (TryNumber(wn-1) == 90) ) {

But this is giving me:

   Error: Expected condition but found expression

Which confuses me, since from what I can tell from parser.h, "TryNumber"
will return a number, (number == 90) should return true or false,
"Refers" returns true or false, and thus (Refers || TryNumber) should
return true or false.

Let me see if I understand your code correctly.  "num" is the number
of matches; if nothing matches, parse_name will return 0 (false);
otherwise, it will return num>0 (true).

NextWord() reads the next word into wd, skipping the next word if it is a 
number.  Then Refers checks the word against the names of the object.
If the next word is not a name, you back up one word ("wn-1") and check
if that is the number 90.  If either is true, you increment num and
continue on, else cease and return num.

I did pull the expression out of the while to see what happened:

   test = ((Refers(self, wd)) || ((TryNumber(wn-1)) == 90));

This gave:

   Error: Operator has too many arguments

Which really confuses me, as I can't tell which operator it's referring to,
and all of the operators seem fine to me.

Hmmmm.

-- 
KEN FAIR - U. Chicago Law  | Power Mac! | Net since '90 | Net.cop
kjfair@midway.uchicago.edu | CABAL(tm) Member | I'm w/in McQ - R U?

  The Internet was not created for companies to make money from.
