Copyright: Copyright © 1995 by Dr.Bob for The Delphi Magazine


TUUCode
TBUUEnCode [image] TBUUDeCode

properties	methods	events

Unit

TBUUCode

Version

2.2 - 1996/01/28

Description

The TUUCode components are just another DLL wrapper, around the UUCODE.DLL. The UUCode dynamic link library implements the uuencode and uudecode file conversion algorithms that can be used to transfer files on the internet (previously used in unix-to-unix file transfers). The objective of uuencoding is to encode a file which may contain any (binary) characters into a another file with a standard character set [`!"#$%&'()*+,-./012356789:;<=>?@ABC...XYZ[\]^_] that can be reliably sent over diverse networks. With the TBUUEnCode component you can encode a file to this standard character set and with the TBUUDeCode you can decode a uuencoded file back to its original (binary) contents.

Note: while this component may seen a bit outdated in this time of www, ftp and webbrowsers, personally I still use it every day when sending binary files from CompuServe to internet or vice-versa (there's no other reliable way to send a binary file from internet to CompuServe, other than to use a standard character set such as the uuencode set).

Author: Dr.Bob


DrBob
 Bob Swart, aka Dr.Bob (100434,2072) is a professional software developer using Borland Pascal, C++ and Delphi, and a free-lance technical writer for The Delphi Magazine. He is co-author of the book "Revolutionary Guide to Delphi 2.0",  published by WROX Press. In his spare time he likes to watch video tapes of Star Trek Voyager with his 2 year old son Erik Mark Pascal.


TDM
You can get a free sample issue of The Delphi Magazine if you send an e-mail message with your name + (postal) address to the editor Chris Frizelle at 70630,717 on CIS or 70630.717@compuserve.com on internet. You can also call or fax him at +44-181-460-0650.


properties

Activate

InputFile

OutputFile


methods

Create

UUEnCode

UUDeCode


events

OnError

OnSuccess


Create

Applies to

TBUUEnCode, TBUUDeCode component

Declaration

constructor Create(AOwner: TComponent);

Description

The constructor Create first checks to see if the UUCODE.DLL is loaded, and if not it raised an exception (so the component is not created). The inherited Create method allocates memory to create the object and initializes its data as needed.


Activate

Applies to

TBUUEnCode, TBUUDeCode component

Declaration

property Activate: Boolean;

Description

The property Activate can be used to (temporarily) activate the uuencode or uudecode process to convert the input file. Note that Activate is set back to False right after the conversion is done, so you'll seldom see its value being at True for more than an instant.


InputFile

Applies to

TBUUEnCode, TBUUDeCode component

Declaration

property InputFile: String;

Description

The property InputFile contains the name of the file that is to be UUEnCoded or UUDeCoded.

There is a special TOpenDialog property editor installed to support the user in selecting the input file at design time.


OutputFile

Applies to

TBUUEnCode component

Declaration

property OutputFile: String;

Description

The property OutputFile contains the name of the file that is the result of the UUEnCoded process (the UUDeCode process is able to determine the original filenames).


UUEnCode

Applies to

TBUUEnCode component

Declaration

procedure UUEnCode;

Description

The objective of uuencoding is to encode the InputFile which may contain any (binary) characters into the OutputFile with a standard character set that can be reliably sent over diverse networks.


UUDeCode

Applies to

TBUUDeCode component

Declaration

procedure UUDeCode;

Description

The objective of uudecoding is to decode the InputFile which may contain any uuencoded files into the original (binary) files.


OnError

Applies to

TBUUEnCode, TBUUDeCode component

Declaration

property OnError: TErrorEvent;

Description

The OnError event can be used to do custom error handling if something went wrong during the UUEncode/UUDecode process. The value of the Error parameter is as follows:

1: input file is output file

2: input file does not exist

3: output file exists

4: could not create output file

5: DLL bussy, try again later (shared buffers)

If an error has occured during the uuencode/uudecode process and the OnError event handler property is not assigned, then an EUUCode exception will be raised with one of the following five messages:

UUCode: input file is output file

UUCode: input file does not exist

UUCode: output file exists

UUCode: could not create output file

UUCode: DLL bussy, try again later (shared buffers)

The last message might be the result of two TUUCode components who's Activate properties have been set to True at (about) the same time. The UUCODE.DLL is using a shared memory buffer for all its clients, so it can only service one at a time.

See Also

OnSuccess


OnSuccess

Applies to

TBUUEnCode, TBUUDeCode component

Declaration

property OnSuccess: TSuccessEvent;

Description

The OnSuccess event can be used to do show some custom message if nothing went wrong during the UUEncode/UUDecode process.

See Also

OnError


TErrorEvent
Type TErrorEvent = procedure(Error: Word) of Object;


TSuccessEvent
Type TSuccessEvent = procedure of Object;


EUUCode
Type EUUCode = class(Exception);