[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Compressing text files

Posted on 2000-04-16
7
Medium Priority
?
189 Views
Last Modified: 2010-04-04
Hi can someone please help me
I am thinking of writeing my own little program for compressing text files and just text files nothing else.
Ok so what i want to now is were I might find some projects, tutors, or code. No OCXS,DLLS,LIBARYS as I now were to find ocx,dlls I just want to make my own prgram form basic code
Thanks.
0
Comment
Question by:dreamvb
7 Comments
 
LVL 17

Expert Comment

by:inthe
ID: 2721127
Hi,
just look at zlib compression unit in the extras folder of your delphi cd,it also comes with example of compressing files.
0
 
LVL 3

Expert Comment

by:bryan7
ID: 2721478
compressing text with ZLIB:

const
  BufferSize = 4096;

var
  functions: Tfunctions;

  BufferZ: array[0..BufferSize-1] of Byte;
  InFile: TStringStream;
  OutFile: TStringStream;
  ZStream: TCustomZLibStream;

function TFunctions.CompressText(Tex: string): string;
begin
  InFile := TStringStream.Create(Tex);
  try
    OutFile := TStringStream.Create('');
    try
      ZStream := TCompressionStream.Create( clFastest, OutFile);
      try
        ZStream.CopyFrom(InFile, 0);
      finally
        ZStream.Free;
      end;
    finally
    Result:= OutFile.DataString;
      OutFile.Free;
    end;
  finally
    InFile.Free;
  end;
end;

function TFunctions.DeCompressText(Tex: string): string;
var Count: Integer;
begin
  InFile :=  TStringStream.Create(Tex);
  try
    OutFile := TStringStream.Create('');
    try
      ZStream := TDecompressionStream.Create(InFile);
      try
        while True do
          begin
            Count := ZStream.Read(BufferZ, BufferSize);
            if Count <> 0 then OutFile.WriteBuffer(BufferZ, Count) else Break;
          end;
      finally
        ZStream.Free;
      end;
    finally
    Result:= OutFile.DataString;
      OutFile.Free;
    end;
  finally
    InFile.Free;
  end;
end;

-------

with a little changes you can use it also with files.. using TFileStream

---

if you don't want to use zlib and make everything for your own.. you can learn how zlib works..
the only things I can teach you are RLA and HUFFMAN compression..
huffman is quite good
0
 
LVL 7

Accepted Solution

by:
Motaz earned 120 total points
ID: 2721678
I write a compression program in Turbo Pascal 7 then I change it to unit to work with Delphi. It works with every file type, and it has a good compression ration in text files. If you need it please write down your E-Mail.

Motaz
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Expert Comment

by:p0seidon
ID: 2722485
Motaz: can you mail me that unit
p0seidon@extended.de

thx
0
 
LVL 4

Author Comment

by:dreamvb
ID: 2724062
Can you send me that Unit please
 to dreamvb@yahoo.com

  Thanks
       Motaz
0
 
LVL 3

Expert Comment

by:bryan7
ID: 2725231
can i have it too ?

brian7@teleline.es

thanks
0
 
LVL 4

Expert Comment

by:Radler
ID: 2726631
Hi Motaz,

I'm very interested at you original code to turbo pascal. I'm looking for a zip/unzip code  to turbo pascal too. Have it you ?

Thanks, Radler( roger@ars.com.br )
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

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

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses
Course of the Month20 days, 3 hours left to enroll

873 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