[address omitted]
Dear George,
“…. I do have something new for you. You or one of the other writers in the last issue mention the lack of any sort of Tasword compresser, like all the PC’s have and such. Well, that is easy to fix! Here, for everyone’s use is what I could only call TasPak, a Tasword file compresser and de-compresser.
Let me back up a little bit first. One obvious way to compress Tasword files is to use Tas>MS, which for most files will make them smaller. It has two problems, though. First, it doesn’t always make it smaller – a file with no spaces, if you can imagine such a thing, becomes 1.5% larger! Second, it isn’t completely reversible. I have written a program to convert Mscript files to Tasword files, but in certian cases the spacing is different in the result.
Still, the basic idea is good. If there are spaces at the end of a line, take them out and replace them with some special character. While we’re at it, why not convert indents and tables to some sort of TAB character? Actually, there are 2 different ways I could have done this. I chose a tab like on a typewriter as opposed to a TAB(x) like in Basic.
Both of these are good, but they only apply to space. What about something that is mostly characters? Well, I follow what happens in PC compression programs – I do read BYTE, after all. So I can tell you what they do. They take groups of characters, and replace them with a single symbol. But they do so in a fashion that depends on the file. That way, a file of all numbers is compressed efficiently, while a file with no numbers is also compressed.
Now, I don’t want to mess around with variable length strings and all that stuff, but I do have one advantage. I know that Tasword uses characters from space to GRAPHICS SHIFT 8, whereas a PC word processor might use others. (In a PC, the other characters are things like è and ó or Greek letters). In other words, Tasword only has 112 possible characters, and I can use the others for pairs of characters. Since I use one for a tab, and one for an end-of-line, that means I have 142 characters to use for pairs of letters.
Now, I was able to use all this in a way that guarantees the result can never be longer, and that is completely reversible. In other words, the result of compressing and then uncompressing is indistinguishable from the original, regardless of what the original might have been. As a further interesting sidenote, if you try to uncompress a file which was not compresssed, nothing will change. Note that trying to compress a compressed file will produce one which couldn’t be interpretted by the un-compresser.
I should mention a possibility that I didn’t use. Since Tasword only uses 112 characters, it would be possible to use a bit compression routine – make every 7 bytes represent 8 characters. This would always compress things by 12.5%. That isn’t bad, but it could be better. I can reasonably say that an average file should be compressed about 40% by my program. Files with a lot of spaces will do even better. The bad news is that there could be a file that achieves no compression at all. I can’t imagine that it would be anything meaningful, but who knows?
Of course this routine has been specifically set up for Tasword. Not knowing about things like printer control codes for Mscript, all I can say is, don’t use it for that.
There is one problem with TasPak. The buffers overlap just a little in memory. That means that if you have a file that starts with 200 blank lines, it won’t uncompress properly. Under presumption that it will only be used on reasonable files, it should never run into problems, but just so you are aware of that limitation. I already said that TasPak was strictly limited to Tasword files, and not to try to compress something twice. Of course, you can always use my Mscript to Tasword converter and then compress – as long as your Mscript file has no printer control characters.
Sincerely,
Steven Gunhouse
BASIC FOR “TasPak.Bz”
100 CLS : PRINT AT 3,8;"Tasword Utility:";AT 4,8;"File Compression";AT 6,5;"by Steven V. Gunhouse"
110 PLOT 60,132: DRAW 0,23: DRAW 159,0: DRAW 0,-39: DRAW -183,0: DRAW 0,39: DRAW 159,0: DRAW 0,-23: DRAW -135,0
120 RANDOMIZE USR 32768
130 PRINT AT 18,0;"File to Load?"''"(ENTER to see CAT)"
140 INPUT "File? "; LINE l$
150 IF l$="" THEN CLS : PRINT #4: CAT ".CT",: GO TO 140
160 FOR i=1 TO LEN l$: IF l$(i)<>"." THEN NEXT i: LET l$=l$+".CT"
170 IF LEN l$<>i+2 THEN GO TO 140
175 IF l$(i+1)<>"C" THEN GO TO 140
180 IF LEN l$>9 THEN GO TO 140
200 PRINT '"Loading ";l$
210 POKE 23728,100
211 PRINT #4: LOAD l$CODE 45056
212 IF PEEK 23728=101 THEN PAUSE 30: GO TO 100
220 CLS : PRINT "File ";l$;" loaded."
230 PRINT AT 8,0;"Options:"
240 PRINT '"1. Compress file."'"2. Uncompress file."
250 PRINT '"Your choice? "
260 PAUSE 0: LET a$=INKEY$: IF a$<"1" OR a$>"2" THEN GO TO 260
270 PRINT AT 13,13;a$
300 IF a$="1" THEN LET len=USR 32808
310 IF a$="2" THEN LET len=USR 32928
350 PRINT ''"Save new file as?"''"(ENTER for same name)"
360 INPUT "Name? "; LINE s$
370 IF s$="" THEN LET s$=l$
380 FOR i=1 TO LEN s$: IF s$(i)<>"." THEN NEXT i: LET s$=s$+".CT"
390 IF i+2<>LEN s$ OR LEN s$>9 THEN GO TO 360
400 IF s$(i+1)<>"C" THEN GO TO 360
410 PRINT '"Saving ";s$;", length=";len
420 PRINT #4: SAVE s$CODE 33280,len
430 INPUT "Another file? (Y/N) ";a$
440 IF a$="" THEN GO TO 100
450 IF a$(1)="Y" OR a$(1)="y" THEN GO TO 100
8990 STOP
9800 RANDOMIZE USR 100: OPEN #4,"dd"
9810 CLEAR 32767
9820 PRINT #4: LOAD "TasPak.Cz"CODE
9830 RUN
9900 PRINT #4: SAVE "TasPak.Bz" LINE 9800
9910 PRINT #4: SAVE "TasPak.Cz"CODE 32768,410
M/C LOADER FOR “TasPak.Cz”
2 CLEAR 32767: LET x1=32767
3 CLS : PRINT AT 10,5;"Loading M/L ..."
4 LET x=1: LET cs=0: LET a=10: LET b=11: LET c=12: LET d=13: LET e=14: LET f=15
5 READ a$: IF a$="END" THEN GO TO 10
6 FOR n=1 TO LEN a$ STEP 2: LET v=16*VAL a$(n)+VAL a$(n+1): POKE x+x1,v: LET x=x+1: LET cs=cs+v*x: NEXT n
7 GO TO 5
10 IF cs<>8896655 THEN PRINT "Error in DATA!": STOP
15 RANDOMIZE USR 100: SAVE "TasPak.Cz"CODE x1,x+1
9949 DATA "2100B006000E4D3E"
9950 DATA "20772310FC0D20F9"
9951 DATA "0E02067036002310"
9952 DATA "FB0D20F83E90068E"
9953 DATA "77233C10FB3680C9"
9954 DATA "CD7E81230600041A"
9955 DATA "13FE202023E52A00"
9956 DATA "FFA7ED52E138587B"
9957 DATA "E63F200B3E1E2BBE"
9958 DATA "28FC23361F18DCCD"
9959 DATA "6C8138DA361E18D3"
9960 DATA "F505280F78362023"
9961 DATA "10FBFE0338057B3D"
9962 DATA "CD5081F1471AFE20"
9963 DATA "20037018B6E521FF"
9964 DATA "FC0E8F0C237E23A7"
9965 DATA "280FB820F61ABE20"
9966 DATA "F2E17113CD378118"
9967 DATA "9AE1CD1A8118F511"
9968 DATA "0082A7ED52444DC9"
9969 DATA "CD7E81230600041A"
9970 DATA "13FE1E200B362023"
9971 DATA "7DCD6C8138F718EC"
9972 DATA "FE1F200A3620237D"
9973 DATA "E63F20F818DEFE20"
9974 DATA "200CE52A00FFA7ED"
9975 DATA "52E138C318D0F505"
9976 DATA "280E7836202310FB"
9977 DATA "FE0338047DCD5081"
9978 DATA "F1FE1E3804FE9038"
9979 DATA "1B4FD690D5E52100"
9980 DATA "FD16005F1919EBE1"
9981 DATA "1A7713231A77D1CD"
9982 DATA "37811897471AFE21"
9983 DATA "300370188ECD1A81"
9984 DATA "18ED70231A7713D5"
9985 DATA "E52100FD3A70FE4F"
9986 DATA "D6905F16001919D1"
9987 DATA "70231A77EBD1C9D5"
9988 DATA "E52170FE545D7E23"
9989 DATA "B928FB1213FE8020"
9990 DATA "F5121B7912E1D1C9"
9991 DATA "E63F4FD5E50C2120"
9992 DATA "FE545D7E23B928FB"
9993 DATA "1213A720F60D1B79"
9994 DATA "12E1D1C9E63F4FD5"
9995 DATA "1120FE1A13B92804"
9996 DATA "A720F837D1C92100"
9997 DATA "FD3E202BBE28FC22"
9998 DATA "00FF1100B021FF81"
9999 DATA "C9","END"
Media
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.