Solved

strip codes from a mIRC log

Posted on 2002-07-05
2
323 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
2 Comments
 
LVL 3

Accepted Solution

by:
raidos earned 20 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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
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…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

744 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now