?
Solved

Compressing text files

Posted on 2000-04-16
7
Medium Priority
?
181 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
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…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

752 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