Solved

Compressing text files

Posted on 2000-04-16
7
170 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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 

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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

760 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

18 Experts available now in Live!

Get 1:1 Help Now