Qompress.Bas 2/

 BBS: Inland Empire Archive
Date: 02-23-93 (08:52)             Number: 323
From: QUINN TYLER JACKSON          Refer#: NONE
  To: ALL                           Recvd: NO  
Subj: Qompress.Bas          2/       Conf: (2) Quik_Bas
>>> Continued from previous message
END FUNCTION

FUNCTION fqjTableInit ()
' This function initializes all compression tables and returns a value
' equal to how many thousandths of a second is required to intialize the
' tables.

StartTime! = TIMER
RESTORE EnglishWordData

FOR i = LBOUND(WordTable$) TO UBOUND(WordTable$)
    READ WordTable$(i)
    WordTable$(i) = WordTable$(i) + " "
NEXT i

RESTORE EnglishTrigramData

FOR i = LBOUND(TriTable$) TO UBOUND(TriTable$)
    READ TriTable$(i)
NEXT i

RESTORE EnglishDigramData

FOR i = LBOUND(DiTable$) TO UBOUND(DiTable$)
    READ DiTable$(i)
NEXT i

fqjTableInit = (TIMER - StartTime!) * 1000

END FUNCTION

FUNCTION funQompress$ (InText$)
STATIC WCount, TCount, DiCount

IF LTRIM$(RTRIM$(InText$)) = "" THEN
    funQompress$ = CHR$(NoType)
    EXIT FUNCTION
END IF

OrigLen = LEN(InText$)

Word$ = fqjSqueeze(InText$, WordTable$())
Tri$ = fqjSqueeze(InText$, TriTable$())
Di$ = fqjSqueeze(InText$, DiTable$())

Word = LEN(Word$)
Tri = LEN(Tri$)
Di = LEN(Di$)

IF Tri < Di AND Tri < Word THEN
    Txt$ = Tri$
    METH$ = CHR$(TriType)
    TCount = TCount + 1
ELSEIF Di < Word THEN
        Txt$ = Di$
        METH$ = CHR$(DiType)
        DiCount = DiCount + 1
ELSE
    Txt$ = Word$
    METH$ = CHR$(WordType)
    WCount = WCount + 1
END IF

SELECT CASE OrigLen > LEN(Txt$)
    CASE -1
        Txt$ = METH$ + MKI$(OrigLen) + Txt$
    CASE ELSE
        Txt$ = CHR$(NoType) + MKI$(OrigLen) + InText$
END SELECT

funQompress$ = Txt$
END FUNCTION


 * SLMR 2.1a *

--- Maximus 2.01wb
 * Origin: VKUG/VPCC QuickBasic Echo - Richmond, BC (1:153/151)
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