Re: [code] error in string parsing

From: Patrick J. Dughi (dughi@IMAXX.NET)
Date: 04/08/98

> I'm trying to parse through this code, (it is for practicing), it
> takes the argument the person types and copies it to another buf while
> looking for the number
> of practices they specified to use. If the remaining argument has no
> number, the number is one, otherwise it (later) tries to atoi the
> argument and get the number.
> It then takes the tempbuf value and tries to find a matching
> skill/spell.

        Aww hell. Mailer code to follow, _and_ beside that its probably
the worse way to do it. Sound familliar?

  char types "prac [words] <#'s of pracs>"

  no prob...

  int pracs=1;
  char oneword[MAX_STRING_LENGTH];

  /* we'll always parse the first argument as a valid skill/spell */

  /* buf is used as a temp buf, and will turn back into 'argument' */

  /* grab the last argument.. i know there's a better way.. i just
     can't think of it right now */

  while(argument=one_argument(argument,oneword)) {
    /* if its in this loop, then argument isn't null */
    /* therefore its not the last argument */
    sprintf(buf," %s%s",buf, oneword);

  /* this is the last word */
  if(oneword && isdigit(*oneword)) {
  } else if (oneword) {
    sprintf(buf," %s%s",buf,oneword);


  /* what you get at the end of this?
      1) argument now only has the skill/spell name in it (even those
         with more than one word)
      2) pracs is equal to the number of pracs they're wanting to
   so, just throw this at the top of your "do_practice" function. */


     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | |

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