seandisanti Posted December 16, 2005 Share Posted December 16, 2005 (edited) ***comments about the script*** just include it and call it with the name of an .au3 file. pass full path or not at your discretion. It will remove blank lines and comments, including block (#cs - #ce) comments, creating a new script in place of the old one, and save the old one in the same place with a .old extension. I didn't put any real error checking in it, as far as checking if file exists or anything, but because of the way it's written, it shouldn't do anything but crash if you give it a nonexistant file. Oh yeah, beta is required. expandcollapse popup#include<file.au3> Func ScriptStripNonCode($Script) $path = "" $pathend = 0 If StringInStr($aScript, "\") Then For $x = 0 To StringLen($Script) If StringMid($Script, StringLen($Script) - $x, 1) = "\" Then $path = StringLeft($Script, StringLen($Script) - $x) $pathend = StringLen($Script) - $x $Script = StringRight($Script, $x) ExitLoop EndIf Next EndIf If StringLen($path) Then FileCopy($path & $Script, $path & StringLeft($Script, StringLen($Script) - 4) & ".old") $Script = $path & $Script Else FileCopy($Script, StringLeft($Script, StringLen($Script) - 4) & ".old") EndIf Dim $source _FileReadToArray($Script, $source) FileDelete($Script) For $z = 1 To $source[0] $tmp = $z Select Case StringInStr($source[$z], ";") If StringRight($source[$z], 1) = "_" Then Do $tmp = $tmp + 1 Until StringRight($source[$tmp], 1) <> "_" EndIf $source[$z] = StringLeft($source[$z], StringInStr($source[$z], ";") - 1) For $y = $z + 1 To $tmp $source[$y] = "" Next $z = $tmp Case StringInStr(StringLower($source[$z]), "#cs") Do $tmp = $tmp + 1 Until StringInStr(StringLower($source[$tmp]), "#ce") For $y = $z To $tmp $source[$y] = "" Next $z = $tmp EndSelect If StringLen(StringStripWS($source[$z], 8)) Then FileWriteLine($Script, $source[$z]) Next EndFunc forgot to code block it the first time. Edited December 16, 2005 by cameronsdad Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now