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
Solved

strip codes from a mIRC log

Posted on 2002-07-05
2
334 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

839 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