Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

strip codes from a mIRC log

Posted on 2002-07-05
2
Medium Priority
?
343 Views
Last Modified: 2012-05-04
hi!, i want to erase any mIRC color codes and or bold reverse underlined... as well.

I need a function which returns the line without any codes...


0
Comment
Question by:joepezt
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 3

Accepted Solution

by:
raidos earned 60 total points
ID: 7132238
I wrote this function in a jiffy, there may be nasty bugs in it but it seems to work...didn't test it much though..

Function StripControlCodes(InStr: String): String;
Var
  ColorLen, Loop, Delta, InStrLen : Integer;

Function StripColors: Integer;
Var
  PassedComma, StillColor: Boolean;
Begin
  Result := 1;
  StillColor := TRUE;
  PassedComma := FALSE;
  While StillColor Do Begin
    Inc(Loop);
    If InStrLen >= Loop Then Begin
      If (InStr[Loop] In ['0'..'9']) OR ((InStr[Loop] = ',') And Not PassedComma) Then Begin
        If InStr[Loop] = ',' Then
          PassedComma := TRUE;
        Inc(Result);

      End Else
        StillColor := FALSE;
    End Else
      StillColor := FALSE;
  End;
End;

Begin
  InStrLen := Length(InStr);
  SetLength(Result, InStrLen);
  Loop := 1;
  Delta := 0;
  While Loop <= InStrLen Do Begin
    Case InStr[Loop] Of
      #3: Begin
        ColorLen := StripColors;
        Inc(Delta, ColorLen);
      End;
      #2, #$F, #$16, #$1F: Begin
        Inc(Delta);
        Inc(Loop);
      End;
      Else Begin
        Result[Loop-Delta] := InStr[Loop];
        Inc(Loop);
      End;
    End;
  End;
  SetLength(Result, Loop-(Delta+1));
End;

Regards
//raidos
0
 

Expert Comment

by:d32coder
ID: 7132301
mIRC has a checkbox to strip codes automatically, look in options.

Don
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question