> 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 */ argument=one_argument(argument,oneword); /* buf is used as a temp buf, and will turn back into 'argument' */ sprintf(buf,"%s",oneword); /* grab the last argument.. i know there's a better way.. i just can't think of it right now */ strcpy(oneword,NULL); 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)) { pracs=atoi(oneword); } else if (oneword) { sprintf(buf," %s%s",buf,oneword); } strcpy(argument,buf); /* 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 spend. so, just throw this at the top of your "do_practice" function. */ PjD +------------------------------------------------------------+ | Ensure that you have read the CircleMUD Mailing List FAQ: | | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html | +------------------------------------------------------------+
This archive was generated by hypermail 2b30 : 12/15/00 PST