Re: your mail

From: Niese-Petersen (Tenp@cris.com)
Date: 10/02/96


On Thu, 3 Oct 1996, The Arrow wrote:

> Hello!
> I am having a little trouble with the isname() function.
> The following two calls both returns true:
>   isname("long sword", "long sword");
>   isname("long sword", "short sword");
> i.e. it uses "long" OR "sword". I want it to use "long" AND "sword" when
> looking through the keyword list, i.e. only the first of the two calls
> above should return true.
> Can anyone please help me with that?

isname() only test one word between words, so to test for "long sword" you
have to do something like this:

  if(isname("long", "long sword") && isname("sword", "long sword"))
/* This is true */
  if(isname("long", "short sword") && isname("sword", "short sword))
 /* this is false */

  So basicaly, you have to test on each word (In this case "long" and
"sword") to get the excact one.


 /* A little quicky */

int test(char *keywords, char *testwords) {
  int ok = TRUE;
  char lookword[256];

  keywords = one_argument(keywords, lookword);

  while(ok && *lookword)
    if(isname(lookword, testwords))
      keywords = one_argument(keywords, lookword);
    else
      ok = FALSE;

  return(ok);
}


Now.. Before anyone come and say "why not just use str_cmp ??", then
remember, its possible that keywords are "long sword" and testwords are
"sword long"  :)

Hope it helps..

---
Erik Niese-Petersen
Aka Quint The typo God
Realms of Darkness IMP [ISP change! Waiting for hardware :( ]




+-----------------------------------------------------------+
| Ensure that you have read the CircleMUD Mailing List FAQ: |
|   http://cspo.queensu.ca/~fletcher/Circle/list_faq.html   |
+-----------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/18/00 PST