SpaceOut 1.0 ---> 1/3

 BBS: Inland Empire Archive
Date: 02-28-93 (21:27)             Number: 67
From: VICTOR YIU                   Refer#: NONE
  To: ALL                           Recvd: NO  
Subj: SpaceOut 1.0 ---> 1/3          Conf: (2) Quik_Bas
'Hello, All!
'
'    After looking at Quinn Tyler Jackson's QOMPRESS, I felt that a faster,
'and tighter compressor for text could be written... and guess what...
'here comes this program!
'
' Part one of SPACEOUT.BAS...
'________O_/________________________| SNIP |______________________\_O_______
'        O \                        | HERE |                      / O

' =============================================
' SpaceOut v1.0  by Victor Yiu  Feb. 26, 1993
' =============================================
'  QBS = YES!
'
' This is a much better compressor of plain text than
' Quinn Tyler Jackson's QOMPRESS, although it does strip
' up characters ASCII >128.  Characters like that are
' almost illegal to post in echos anyway, so it really
' doesn't matter.
'
' What is different is that this compressor is FAST
' in just QB only code.  It is optimized TO THE MAX!
' With direct string manipulation (no more MID$) and
' block transfers, it is the fastest text compression
' code I have seen.  Even faster compiled!
'
' I have done some benchmarking... and here are the
' results:
'
' All tests run compiled on a 486/34. Input file:
' TELIX.DOC (documentation file for Telix 3.21) (215K)
' +--------------------------+--------------------------+
' |         QOMPRESS         |         SPACEOUT         |
' +--------------------------+--------------------------+
' |    Saved 28956 bytes     |    Saved 42389 bytes     |
' | Time required: 27.6 secs.| Time required: .38 secs. |
' +--------------------------+--------------------------+
'
' That's right, folks -- SPACEOUT is 75 times faster --
' and it compresses text 46% better.  ;-)  Sorry, Quinn...
' no bashing intended...  would this be helpful to
' QBCIMR?  It is a small, yet powerful and fast routine
' that can be applied easily...  You can run vy.Encode
' for every message (I'm glad they are <16K).  Average
' compression savings are around 20%.
'
' Well, granted, it isn't going to compress it as well
' as PKZIP or ARJ, but it's just a beginning.  It's in
' 100% QB and it's fast.
'
' Warning: DO NOT BREAK OUT WHEN IT IS COMPRESSING.  The
'   data you are compressing will be corrupted.

DECLARE FUNCTION vy.Decode% (Text$)
DECLARE FUNCTION vy.Encode% (Text$)

DEFINT A-Z
CONST True = -1, False = 0

PRINT
PRINT "SpaceOut v1.0  by Victor Yiu  Public Domain"
PRINT STRING$(45, "~")
PRINT

F$ = COMMAND$
IF LEN(F$) = 0 THEN INPUT "Filename"; F$

OPEN F$ FOR BINARY AS #1
InL& = LOF(1)
OutL& = 0

PRINT
PRINT "Sawing <G>...";
T! = TIMER

DO
    SELECT CASE InL& - SEEK(1) + 1
        CASE IS > 8192
            Block$ = SPACE$(8192)
        CASE IS <= 0
            EXIT DO
        CASE ELSE
            Block$ = SPACE$(InL& - SEEK(1) + 1)
    END SELECT
    GET #1, , Block$

    Ok = vy.Encode(Block$)
    IF NOT Ok THEN EXIT DO

    OutL& = OutL& + LEN(Block$)
LOOP
CLOSE

'Continued on next message...

--- Blue Wave/RA v2.10 [NR]
 * Origin: Hard Disc Cafe / Houston Texas / (713) 589-2690
/ Node -*N (1:106/30.0)
Outer Court
Echo Basic Postings

Books at Amazon:

Back to BASIC: The History, Corruption, and Future of the Language

Hackers: Heroes of the Computer Revolution (including Tiny BASIC)

Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution

The Advent of the Algorithm: The Idea that Rules the World

Moths in the Machine: The Power and Perils of Programming

Mastering Visual Basic .NET