This is how I do.. right, wrong, indifferent.
It works.

If you call this more than once inside a printf/sprintf or whatever,
you'll need to strcpy the results into a char. Otherwise it'll trash itself.

char *remove_color(char *string)
{
   static char newstring[MSL];
   int counter=0, i;
   int len;
   if (!string[0]) return NULL;
   len = strlen(string);
   for (i=0; i<len; i++){
      if (string[i]=='{' || (i>=1 && string[i-1] == '{'))
                continue;
      if (string[i]=='}')
                continue;
      newstring[counter]=string[i];
      counter++;
   }
   newstring[counter]=0;
   return newstring;
}

>-----Original Message-----
>From: TandonMiir [mailto:[EMAIL PROTECTED]
>Sent: Thursday, May 09, 2002 9:14 PM
>To: [email protected]
>Subject: Re: Limit color
>
>
>> if(*pointer == '{') /*this "{" is infact the color pointer 
>on my mud*/
>> {
>> pointer++;
>> bufin++;
>> if(*pointer == 'z') /*blinking text reserved*/
>
>This is why.  The if statements that are to different letters 
>are to remove
>only certain types (in this case clear screen, blinking and 
>beeping). If you
>want to remove ALL color, then set it to strip the second character
>following a { no matter what it is.
>
>And if you need help with that, here's the code.
>
>  if(*pointer == '{')
>  {
>   *bufin = ' ';        /*remove {*/
>
>   pointer++;
>   bufin++;
>
>   *bufin = ' ';        /*remove following char*/
>  }
>
>Say a mortal enters
>
>' {Bblue '
>
>It will send this to the game:
>
>'   blue '
>
>Still working on how to remove the chars without the added spaces.
>
>~Tandon
>
>
>-- 
>ROM mailing list
>[email protected]
>http://www.rom.org/cgi-bin/mailman/listinfo/rom
>

Reply via email to