Solved

Compressing text files

Posted on 2000-04-16
7
171 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 30 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
delphi prevent click fast 2 189
find a node in VST 2 63
Controlled Assessment GCSE - desperate help needed 4 75
creating threads in delphi 1 81
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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Delivering innovative fully-managed cloud services for mission-critical applications requires expertise in multiple areas plus vision and commitment. Meet a few of the people behind the quality services of Concerto.
Need to grow your business through quality cloud solutions? With everything required to build a cloud platform and solution, you may feel like the distance between you and the cloud is quite long. Help is here. Spend some time learning about the Con…

932 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now