Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #COMPILE EXE
- #DIM ALL
- FUNCTION PBMAIN () AS LONG
- DIM lastbyte$
- lastbyte$ = " "
- DIM infile$
- DIM outfile$
- IF COMMAND$ = "" THEN
- INPUT "INPUT FILE?", infile$
- INPUT "OUTPUT FILE?", outfile$
- ELSE
- infile$ = COMMAND$(1)
- outfile$ = COMMAND$(2)
- END IF
- DIM tempcount AS INTEGER
- lastbyte = ""
- DIM buffer$
- buffer$ = " "
- KILL outfile$
- OPEN infile$ FOR BINARY AS #1
- OPEN outfile$ FOR BINARY AS #2
- tempcount = 0
- DIM temp$
- temp$ = " "
- PUT #2, , temp$ ' FILLER FOR FILE SIZE
- PUT #2, , temp$ ' FILLER FOR FILE SIZE
- DIM init&
- init& = 1
- WHILE NOT EOF(1)
- GET #1, , buffer$
- IF buffer$ = lastbyte THEN
- tempcount = tempcount + 1
- ELSE
- IF tempcount = 1 THEN
- temp$ = CHR$(0)
- PUT #2, , lastbyte$
- PUT #2, , temp$
- lastbyte = buffer$
- tempcount = 0
- ELSEIF tempcount = 0 THEN
- IF init& = 1 THEN
- init& = 0
- lastbyte = buffer$
- tempcount = 0
- ELSE
- PUT #2, , buffer$
- lastbyte = buffer$
- tempcount = 0
- END IF
- ELSEIF tempcount > 1 THEN
- temp$ = CHR$(tempcount - 1)
- PUT #2, , lastbyte$
- PUT #2, , lastbyte$
- PUT #2, , temp$
- lastbyte = buffer$
- tempcount = 0
- END IF
- END IF
- WEND
- CLOSE #1
- CLOSE #2
- OPEN outfile FOR BINARY AS #2 ' WRITE FILESIZE (1xWORD)
- DIM temp2$
- temp2$ = SPACE$(LOF(2))
- GET #2, , temp2$
- CLOSE #2
- OPEN outfile FOR BINARY AS #2
- temp$=CHR$(INT(LOF(2) / 256))
- MID$(temp2$,1,1) = temp$
- temp$ = CHR$(LOF(2) MOD 256)
- MID$(temp2$,2,1) = temp$
- PUT #2, ,temp2$
- CLOSE #2
- END FUNCTION
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement