Oberon/ETH Oberon/Tutorial/Compress

These tutorial pages were written by André Fischer (afi) with editorial assistance of Hannes Marais, were hosted at the ETHZ and remain under the ETH license. Related content is found in the system via Book.Tool. Extended content is also available on paper. Some tutorial pages are in the WayBack archive.

Compression and Archiving Tools

Tutorial objective

edit

Learn how to handle or create compressed files and archive files distributed on diskette, by FTP and by e-mail.

Estimated time: 20 minutes.


Compress

edit

Compress compresses several files using the LZSS compression technique and packs them into a single archive file. An archive (file) is portable among all Oberon platforms. By convention, the last part of an archive name should be Arc. A file having a file name extension .Arc can be opened directly with the command Desktops.OpenDoc (see below).

Caution: An Oberon archive is a binary file. To send it by e-mail it must be processed by the AsciiCoder.CodeFiles command.

Principle of operation

edit

LZSS uses a dictionary-based compression scheme: it uses previously seen text as a dictionary and replaces phrases in the input text with pointers into the dictionary to achieve compression. The LZSS compression algorithm is highly asymmetrical. The compression routine is fairly complicated and does quite a bit of work. In comparison, the expansion code is extremely simple and has little work to do. This makes LZSS an excellent choice for data that needs to be compressed once and expanded many times.

More information on the LZSS compression technique can be found in:

The Data Compression Book
Mark Nelson
M & T Publishing - ISBN 0-13-202854-9

Compress performs the same functions as the common Unix programs compress and uncompress, together with the Unix tape archiver tar. TAR simply takes a group of files and combines them into a single file, and does not perform any compression.

Note the difference of strategy between Unix and Oberon. A Unix .tar.Z file is a compressed (tape) archive. An Oberon archive contains individually compressed files, which makes it easy to add, extract, or delete files in an archive. As a result, the format of an Oberon archive is not compatible with that of a file produced by the UNIX utility.

Maintaining an archive document

edit

Maintenance work on an archive file starts by opening the document with the command Desktops.OpenDoc. Try this example using a file name Archive.Arc:

Desktops.OpenDoc Archive.Arc

This opens a document viewer of that name, displaying a directory of the files contained in the archive. If the archive does not yet exist, it is automatically created. The same result can be obtained by executing the Compress.Directory command, described below. Maintenance work can be comfortably performed with the help of the command buttons in the menu bar. Each button in the title bar, except [Close], executes a command defined in the Compress module:

[Open ^] Compress.Open ^
[Add ^] Compress.Add ^
[Extract ^]   Compress.Extract ^
[Delete ^] Compress.Delete ^

These commands are described below.

The compress commands are collected in the Compress.Tool.

Display archive directory - Compress.Directory

edit

Compress.Directory [\d] (archiveName | ^) opens a text viewer named archiveName listing the names of the files contained in the archive. If the archive does not yet exist, it is automatically created. When the option \d is present, additional information is given for each file: date and time when added to the archive, compressed size in bytes, and size in percent of the original uncompressed file.

Add a list of files - Compress.Add

edit

Compress.Add archiveName ({fileName} ~ | ^) compresses and adds the named files to the named archive. If a file with a matching name already exists, its name is suffixed with a sequence number, as is shown here: if Char.Mod exists, Char.Mod0 is added.

Extract all files - Compress.ExtractAll

edit

Compress.ExtractAll archiveName extracts and decompresses all the files from the named archive, placing them in the current directory.
Caution: If a file with a matching name already exists, it is overwritten. A warning message is written to the Oberon log.

Extract a list of files - Compress.Extract

edit

Compress.Extract archiveName ({fileName} ~ | ^) extracts and decompresses the named files from the named archive, placing them in the current directory.
Caution: If a file with a matching name already exists, it is overwritten. A warning message is written to the Oberon log.

Delete a list of files - Compress.Delete

edit

Compress.Delete archiveName ({fileName} ~ | ^) deletes the named files from the named archive.

Open a file - Compress.Open

edit

Compress.Open archiveName (fileName | ^) opens a document viewer named fileName displaying the named file in the named archive. Use this command if you wish to display the contents of one of the compressed file without actually creating (or replacing) the file in the current directory.

Definitions.Arc - An example of archive

edit

Definitions.Arc is an important and central archive in Oberon, because it is the information repository in which Watson may be requested to search module definitions. An alternative way to display a module definition stored in that archive, is to display its directory with Desktops.OpenDoc Definitions.Arc, to select a name in the list and to click on the [Open ^] button in the title bar, or to use the Compress.Open command.


AsciiCoder encoder/decoder

edit

The AsciiCoder encodes and decodes a text or the most recently selected text, also including gadgets, appearing in a document viewer. It can also be used to encode and decode arbitrary files. The data stream generated by encoding is made only of printable ASCII characters and is apt to be sent by electronic mail. It is always presented in a text viewer where it can be edited to become a part of an e-mail message for instance. In addition, the encoded data is preceded by the adequate command for decoding it, that is AsciiCoder.DecodeText or AsciiCoder.DecodeFiles according to the case. The decoding command will automatically obtain the information on the amount of information to decode, i.e. it knows where the encoded data ends. An Oberon user who receives such an e-mail, can immediately decode the information.

Encode a text - AsciiCoder.CodeText

edit

AsciiCoder.CodeText [%] (* | @) encodes the text, including gadgets, of the marked viewer (*), or if the command is followed by @, the text contained in the most recent selection. When the % option is present, the text is compressed at the same time. A document viewer named "AsciiCoder.CodeText" is automatically opened. It presents the encoded data preceded by an appropriate AsciiCoder.DecodeText [%] command.

Encode a list of files - AsciiCoder.CodeFiles

edit

AsciiCoder.CodeFiles [%] ({fileName} ~ | ^) encodes all the files named in the list or all the files named in the selection. When the % option is present, the files are compressed at the same time. A document viewer named "AsciiCoder.CodeFiles" is automatically opened. It presents the encoded data preceded by an appropriate AsciiCoder.DecodeFiles [%] {fileName} ~ command.

Decode a text - AsciiCoder.DecodeText

edit

AsciiCoder.DecodeText [%] (text | @) decodes the Ascii encoded text which follows the command, or the text starting at the beginning of the most recent selection. A document viewer named "AsciiCoder.DecodeText" is automatically opened, presenting the decoded information. When the % option is present, the text is expanded at the same time.

Decode a list of files - AsciiCoder.DecodeFiles

edit

AsciiCoder.DecodeFiles [%] ({fileName} ~ text | @) decodes the Ascii encoded text which follows the command, or the text starting at the beginning of the most recent selection. The contained files are written in the current directory. Existing files are not overwritten since they are first renamed to .Bak files. The file names must appear at the beginning of the selection, ahead the coded data. The command AsciiCoder.CodeFiles takes care of that. When the % option is present, the files are expanded at the same time.

The Desktops.OpenDoc AsciiCoder.Tool presents in a handkerchief a useful collection of the commands just described, in all variants.


Base64 encoder/decoder

edit

The Base64 module encodes and decodes a file, even including gadgets. The data stream generated by encoding is made only of 64 ASCII characters and is apt to be sent by electronic mail. It is always presented in a text viewer where it can be edited to become a part of an e-mail message for instance.

Encode a file - Base64.Encode

edit

Base64.Encode fileName encodes the named file. A document viewer named "Encode" is automatically opened. It presents the encoded data.

Decode a text and store it in a file - Base64.Decode

edit

Base64.Decode fileName (~ | ^) decodes the encoded text which follows the fileName ~, or if the fileName is followed by ^, the text starting at the most recent selection. The result is written in the named file in the current directory.
Caution: If a file with a matching name exists on the hard disk, it is overwritten.


UUDecoder

edit

Unix uuencoded files are frequently posted to Usenet newsgroups or sent as mail messages. A uuencoded file is a binary file that has been encoded as a text file by the Unix uuencode program. Note that this transformation inflates the binary file rather than compress it!

If you happen to receive such a file, you may decode it with the UUDecoder.Decode command which is documented in the UUDecoder.Tool and below.

Decode a text - UUDecoder.Decode

edit

UUDecoder.Decode begin .... | @ decodes the text which follows the command, or the text starting at the beginning of the most recent selection.

Decode a list of files - UUDecoder.Decode

edit

UUDecoder.Decode {fileName} ~ | ^ decodes all the files named in the list or all the files named in the selection.

Overview

edit

 

 

What's next?

edit

Distribute your custom developed Oberon extensions in compressed format or as Oberon archive files, by e-mail or by uploading them by FTP on an FTP server for instance.


Index

edit

A

archive
AsciiCoder.CodeFiles
AsciiCoder.CodeText
AsciiCoder.DecodeFiles
AsciiCoder.DecodeText
AsciiCoder.Tool
AsciiCoder

B

Base64.Decode
Base64.Encode
Base64

C

compress (Unix)
Compress.Add
Compress.Delete
Compress.Directory
Compress.ExtractAll
Compress.Extract
Compress.Open
Compress.Tool
compress

D

Definitions.Arc

E

encode/decode

T

tar (Unix)

U

uudecode (Unix)
UUDecoder.Decode
UUDecoder.Tool


Revised on July 6, 1996
Installed on 30 05 1997