Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,52 @@
|
|||
Module BBCtrans {
|
||||
\\ LZW compression
|
||||
plaintext$="TOBEORNOTTOBEORTOBEORNOT"
|
||||
Function encodeLZW$(i$) {
|
||||
Def long c, d, i, l, o$, w$
|
||||
DIM dict$(0 to 4095)
|
||||
FOR i = 0 TO 255 : dict$(i) = CHR$(i) : NEXT i
|
||||
l = i
|
||||
i = 1
|
||||
w$ = LEFT$(i$,1)
|
||||
REPEAT{
|
||||
d = 0
|
||||
REPEAT {
|
||||
c = d
|
||||
IF i > LEN(i$) THEN EXIT
|
||||
FOR d = 1 TO l-1
|
||||
IF w$ = dict$(d) THEN EXIT
|
||||
NEXT d
|
||||
IF d < l Then i += 1 : w$ += MID$(i$, i, 1)
|
||||
} UNTIL d >= l
|
||||
dict$(l) = w$ : l += 1 : w$ = RIGHT$(w$, 1)
|
||||
o$ += CHR$(c MOD 256) + CHR$(c DIV 256)
|
||||
} UNTIL i > LEN(i$)
|
||||
= o$
|
||||
}
|
||||
encodeLZW$ = encodeLZW$(plaintext$)
|
||||
FOR i = 1 TO LEN(encodeLZW$) STEP 2
|
||||
PRINT ASC(MID$(encodeLZW$,i)) + 256*ASC(MID$(encodeLZW$,i+1));" ";
|
||||
NEXT i
|
||||
Print
|
||||
Function decodeLZW$(i$) {
|
||||
Def c, i, l, o$, t$, w$
|
||||
DIM dict$(0 to 4095)
|
||||
FOR i = 0 TO 255 : dict$(i) = CHR$(i) : NEXT i
|
||||
l = i
|
||||
c = ASC(i$) + 256*ASC(MID$(i$,2))
|
||||
w$ = dict$(c)
|
||||
o$ = w$
|
||||
IF LEN(i$) < 4 THEN = o$
|
||||
FOR i = 3 TO LEN(i$) STEP 2
|
||||
c = ASC(MID$(i$,i)) + 256*ASC(MID$(i$,i+1))
|
||||
IF c < l Then { t$ = dict$(c) } ELSE t$ = w$ + LEFT$(w$,1)
|
||||
o$ += t$
|
||||
dict$(l) = w$ + LEFT$(t$,1)
|
||||
l += 1
|
||||
w$ = t$
|
||||
NEXT i
|
||||
= o$
|
||||
}
|
||||
Print decodeLZW$(encodeLZW$)
|
||||
}
|
||||
BBCtrans
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
Module FastM2000 {
|
||||
plaintext$="TOBEORNOTTOBEORTOBEORNOT"
|
||||
Function encodeLZW$(i$) {
|
||||
Def long c, d, i, l, o$, w$
|
||||
Inventory dict
|
||||
For i = 0 to 255 {Append dict , Chr$(i):=i}
|
||||
l = i
|
||||
i = 1
|
||||
w$ = LEFT$(i$,1)
|
||||
REPEAT{
|
||||
d = 0
|
||||
Repeat {
|
||||
c = d
|
||||
IF i > Len(i$) Then Exit
|
||||
if exist(dict, w$) Then {
|
||||
d=eval(dict)
|
||||
} Else Append dict, w$:=l: Exit
|
||||
if d<l Then i += 1 : w$ += Mid$(i$, i, 1)
|
||||
} Until d >= l
|
||||
l += 1 : w$ = Right$(w$, 1)
|
||||
o$ += Chr$(c Mod 256) + Chr$(c div 256)
|
||||
} Until i > Len(i$)
|
||||
= o$
|
||||
}
|
||||
encodeLZW$ = encodeLZW$(plaintext$)
|
||||
Document Doc$
|
||||
For i = 1 to Len(encodeLZW$) STEP 2
|
||||
Doc$= Str$(Asc(Mid$(encodeLZW$,i)) + 256*Asc(Mid$(encodeLZW$,i+1)))
|
||||
Next i
|
||||
Doc$={
|
||||
}
|
||||
Function decodeLZW$(i$) {
|
||||
Def c, i, l, o$, t$, w$
|
||||
Inventory Dict
|
||||
For i = 0 to 255 {Append dict , i:=chr$(i)}
|
||||
l = i
|
||||
c = Asc(i$) + 256*Asc(Mid$(i$,2))
|
||||
w$ = dict$(c)
|
||||
o$ = w$
|
||||
IF Len(i$) < 4 Then = o$
|
||||
For i = 3 to Len(i$) STEP 2 {
|
||||
c = Asc(Mid$(i$,i)) + 256*Asc(Mid$(i$,i+1))
|
||||
IF c < l Then {
|
||||
t$ = dict$(c)
|
||||
} Else t$ = w$ + LEFT$(w$,1)
|
||||
o$ += t$
|
||||
Append dict, l:=w$ + LEFT$(t$,1)
|
||||
l += 1 : w$ = t$
|
||||
}
|
||||
= o$
|
||||
}
|
||||
Doc$=decodeLZW$(encodeLZW$)+{
|
||||
}
|
||||
Clipboard Doc$
|
||||
Report Doc$
|
||||
}
|
||||
FastM2000
|
||||
Loading…
Add table
Add a link
Reference in a new issue