|
PAKER
Dec 17, 2021 11:57:25 GMT -6
Post by rosy on Dec 17, 2021 11:57:25 GMT -6
I made a file compressor, but I don't know why RPAK works forever ... EOF not working?
Sub PAK(plik$)
n=0
a=0
FileOpen(0, plik$, BINARY_INPUT)
FileOpen(1, plik$+".pak", BINARY_OUTPUT)
b=ReadByte(0)
For i=1 to FileLength(plik$)-1
a=ReadByte(0)
If a=b AND n<255 then
n=n+1
Else
WriteByte(1, b)
WriteByte (1, n )
n=0
End If
b=a
Next
WriteByte(1, b)
WriteByte (1, n )
FileClose(0)
FileClose(1)
End Sub
Sub RPAK(plik$)
n=0
a=0
FileOpen(0, plik$, BINARY_INPUT)
Do
b=ReadByte(0)
n=ReadByte(0)
For i=0 to n
print Chr$(b);
print n
wait(100)
Next
Loop until Eof(0)
FileClose(0)
End Sub
'PAK ("TEST.TXT")
RPAK ("TEST.TXT.pak")
|
|
|
PAKER
Dec 17, 2021 12:44:31 GMT -6
Post by n00b on Dec 17, 2021 12:44:31 GMT -6
I will try it out today. I will get the issue with EOF fixed in the next release. In the meantime you can use FileLength() to get the size of the file in bytes and just read that many bytes.
|
|