Advertisement
Guest User

Untitled

a guest
Jan 24th, 2011
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.19 KB | None | 0 0
  1. function matchcount(%a,%b)
  2. {
  3.     %j = 0;
  4.    
  5.     for(%i = -1; (%i = striPos(%a,%b,%i + 1)) != -1; %j++)
  6.     {
  7.     }
  8.    
  9.     return %j;
  10. }
  11.  
  12. function MDcompress(%a,%b)
  13. {
  14.     new fileobject(f);
  15.     f.openforread(%a);
  16.    
  17.     %a = "";
  18.    
  19.     while(!f.isEOF())
  20.         %a = %a @ f.readline();
  21.    
  22.     for(%i = 10; %i >= 2; %i--)
  23.     {
  24.         for(%d = 20; %d >= 4; %d--)
  25.         {
  26.             for(%j = 0; %j < strlen(%a) - %d; %j++)
  27.             {
  28.                 %e = getsubstr(%a,%j,%d);
  29.                
  30.                 if(matchcount(%a,%e) >= %i)
  31.                 {
  32.                     if(strlen(%c) < strlen($c))
  33.                     {
  34.                         %m = %e TAB %m;
  35.                         %a = strreplace(%a,%e,getsubstr($c,strlen(%c),1));
  36.                         %a = strreplace(%a,strlwr(%e),getsubstr($c,strlen(%c),1));
  37.                         %c = getsubstr($c,strlen(%c),1) @ %c;
  38.                     }
  39.                     else
  40.                         break;
  41.                 }
  42.             }
  43.         }
  44.     }
  45.    
  46.     f.delete();
  47.     new fileobject(f);
  48.     f.openforwrite(%b);
  49.    
  50.     f.writeline("//" @ %a);
  51.     f.writeline("new fileobject(f).openforread($con::file);%f=f.readline();%i=-1;while(%i++<"   @
  52.                 strlen(%c) + 1 @ ")%f=strreplace(%f,getsubstr(\"" @ %c @ "\",%i,1),getField(\"" @
  53.                 strlwr(strreplace(expandEscape(%m),"\\t","  ")) @ "\",%i));eval(getsubstr(%f,2" @
  54.                 ",strlen(%f)));");
  55.    
  56.     f.close();
  57.     f.delete();
  58.    
  59.     echo("compressed");
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement