Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function matchcount(%a,%b)
- {
- %j = 0;
- for(%i = -1; (%i = striPos(%a,%b,%i + 1)) != -1; %j++)
- {
- }
- return %j;
- }
- function MDcompress(%a,%b)
- {
- new fileobject(f);
- f.openforread(%a);
- %a = "";
- while(!f.isEOF())
- %a = %a @ f.readline();
- for(%i = 10; %i >= 2; %i--)
- {
- for(%d = 20; %d >= 4; %d--)
- {
- for(%j = 0; %j < strlen(%a) - %d; %j++)
- {
- %e = getsubstr(%a,%j,%d);
- if(matchcount(%a,%e) >= %i)
- {
- if(strlen(%c) < strlen($c))
- {
- %m = %e TAB %m;
- %a = strreplace(%a,%e,getsubstr($c,strlen(%c),1));
- %a = strreplace(%a,strlwr(%e),getsubstr($c,strlen(%c),1));
- %c = getsubstr($c,strlen(%c),1) @ %c;
- }
- else
- break;
- }
- }
- }
- }
- f.delete();
- new fileobject(f);
- f.openforwrite(%b);
- f.writeline("//" @ %a);
- f.writeline("new fileobject(f).openforread($con::file);%f=f.readline();%i=-1;while(%i++<" @
- strlen(%c) + 1 @ ")%f=strreplace(%f,getsubstr(\"" @ %c @ "\",%i,1),getField(\"" @
- strlwr(strreplace(expandEscape(%m),"\\t"," ")) @ "\",%i));eval(getsubstr(%f,2" @
- ",strlen(%f)));");
- f.close();
- f.delete();
- echo("compressed");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement