mIRC Homepage
Posted By: gaui Strip color codes - 05/09/04 05:07 AM
I've got this log file with all these color codes (bold, underline, color).

Is there a way I can strip all these codes without doing replace on all  ?
Posted By: Mentality Re: Strip color codes - 05/09/04 05:56 AM
/help $strip smile

You can automatically strip log files in mIRC Options: ALT+O > IRC > Logging - Check the box 'Strip codes'.

Regards,
Posted By: gaui Re: Strip color codes - 05/09/04 06:00 AM
I have to strip a file with MANY lines. smile
Posted By: gemeau50 Re: Strip color codes *DELETED* - 05/09/04 11:05 AM
Message effacé par gemeau50

Sorry that I erased my message, I didn't notice that there was a reply to it.

The command I was refering to and didn't work was:

/filter -ffb infile outfile *
Posted By: tidy_trax Re: Strip color codes - 05/09/04 11:10 AM
The keyword there is matching, so if you used "hello" as the matchtext, it would find hello regardless of how many control codes were around it.
Posted By: dr_Eamer Re: Strip color codes - 05/09/04 01:37 PM
Here's how I would do it:
alias stripfile { filter -fk $$1 _stripfile * | .copy -o stripfile.tmp $1 | .remove stripfile.tmp }
alias -l _stripfile { write stripfile.tmp $strip($1) }


Usage:
/stripfile file
eg. /stripfile mylog.txt


Warning: This will overwrite the old file.

Note that there is a mIRC option to strip off color codes while logging:
Alt-O -> IRC -> Logging -> Strip Codes (checkbox, 3rd on the left)

Edit: That's a cool feature suggestion! A filter switch that strips codes in output!
Posted By: Sigh Re: Strip color codes - 05/09/04 03:06 PM
Good idea, though if the file has control codes on every single line, or the majority of lines, I'd use file handling commands rather than /write for speed. But if the control codes aren't so abundant then it's possible to only filter the necessary lines:

/filter -nfkg file myalias /[[:cntrl:]]/
alias myalias { tokenize 32 $1 | write -l $+ $1 file $strip($2-) }
Posted By: dr_Eamer Re: Strip color codes - 05/09/04 04:36 PM
Cool!

File handling would surely be faster, but then again how many times would someone need to run this? I just preffered the simpler, faster-written code against the more complicated but faster-executed code.

Also, I didn't know you could edit the file while filtering it. I guess I was too lazy to try it and check it out for myself...
I didn't know about the :cntrl: class either...
Thanx
Posted By: Online Re: Strip color codes - 07/09/04 02:11 AM
Quote:
Also, I didn't know you could edit the file while filtering it.

The truth is that the lines are not being played to the -k alias "on the fly." Instead, they are copied into a separate buffer from which you start receiving them only after the input file (or window) is released. More on this here.
Posted By: dr_Eamer Re: Strip color codes - 07/09/04 10:13 AM
Cool! smile
Thanx for the info!
It's so good to know!
© mIRC Discussion Forums