=========================================================================== BBS: The Abacus * HST/DS * Potterville MI Date: 02-28-93 (21:28) Number: 14 From: VICTOR YIU Refer#: NONE To: ALL Recvd: NO Subj: SpaceOut 1.0 ---> 2/3 Conf: (35) Quick Basi --------------------------------------------------------------------------- 'Part 2 of SPACEOUT.BAS - continued from last message... IF Ok THEN LOCATE , 1 PRINT USING "Time elapsed: ###.## seconds."; TIMER - T! PRINT PRINT "Results:" PRINT " Compression percentage: "; PRINT USING "###.#%"; (InL& - OutL&) * 100 / InL& PRINT " In:"; InL&; " Out:"; OutL& PRINT " Bytes saved: "; InL& - OutL&; "out of"; InL& PRINT PRINT "Happy compression!" ELSE PRINT "Compression aborted or error occured." IF InL& = 0 THEN PRINT "File does not exist." END IF END ' This function expands the compressed code generated by vy.Encode. ' It is a little more complicated because it has to create extra ' spaces without using string concentration (A$ + B$ ...) -- that ' would be toooo slow. ' FUNCTION vy.Decode (Text$) Leng = LEN(Text$) IF Leng = 0 THEN Decode = True: EXIT FUNCTION OrigLen = CVI(LEFT$(Text$, 2)) IF OrigLen > Leng - 2 THEN ' doing something if two blocks END IF ' of code are squished together... ' but try to avoid it... Add = OrigLen - LT IF Add > 0 THEN Text$ = SPACE$(Add + 1) + MID$(Text$, 3) Temp& = SSEG(Text$) ' QB USERS: REPLACE ' "SSEG" with VARSEG Offset = SADD(Text$) DEF SEG = Temp& + Offset \ 16 After = Offset AND 15 Offset = After + Add IF Add THEN Offset = Offset + 1 Endd = Offset + Leng - 1 Abort = False Ok = True FOR Byte = Offset TO Endd IF After > Byte THEN PRINT "Input is corrupted!" Ok = False EXIT FOR END IF Char = PEEK(Byte) IF Char > 127 THEN POKE After, Char AND 127 After = After + 1 POKE After, 32 ELSE POKE After, Char END IF After = After + 1 NEXT DEF SEG Text$ = LEFT$(Text$, OrigLen) IF NOT Ok THEN Text$ = RTRIM$(Text$) vy.Decode = Ok END FUNCTION ' My principal is simple. Since the SPACE (ASCII 32) character is the ' most commonly found character in English text, and the high bit of ' the text is not used, I have decided to compress the space into the ' one bit. What I mean: If the next character is a space, turn the ' high bit on. If it is not, leave it off. ' ' So this input: weiu weoiru weoiu q ' ' would come out 3 characters shorter, since the spaces are represented ' by the high bit of the previous character. If the input has two ' incoming spaces, however, the 1st space will be encoded w/the last '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) SEEN-BY: 1/211 11/2 4 13/13 101/1 108/89 109/25 110/69 114/5 123/19 124/1 SEEN-BY: 153/752 154/40 77 157/2 159/100 125 430 950 203/23 209/209 280/1 SEEN-BY: 390/1 396/1 15 397/2 2230/100 3603/20