[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Need help with Binscii
- Subject: Re: Need help with Binscii
- From: toddpw@avarice.ugcs.caltech.edu (Todd P. Whitesel)
- Date: 8 Oct 1994 09:34:08 GMT
- Newsgroups: comp.sys.apple2
- Organization: California Institute of Technology, Pasadena
- References: <3750tk$12g@cnct.com>
radelgre@cnct.com (radelgre) writes:
>I tried to EXEC the Binscii.exe file. I checked, and there was nothing
>before the first or after the last REM. I downloaded this version from
>caltech. The system gave me 19 SYntax errors (with the appropriate
>beeps). I am using the BASIC that came with 6.0.1. Please help.
Sounds like a newline conversion problem. Unix machines use Ctrl-J instead
of Return between each line, so if you use binary mode to transfer the
file to your Apple, it will look like it is one huge line of barber-pole
text, and you'll get a syntax error for every 249 or so characters of it.
To fix it, type this in and run it, then try the EXEC again.
10 F$ = "binscii.exe" : REM replace this string with the name of the exec file
20 D$ = CHR$(4)
30 HGR:HGR2:TEXT : REM this is a sneaky way to get blank memory to work in
40 ?D$"BLOAD "F$",TTXT,A8192"
50 X = 8192
60 IF PEEK(X) = 10 THEN POKE X,13 : REM convert unix newline to apple return
70 IF PEEK(X) <> 0 THEN X=X+1: GOTO 60
80 ?D$"BSAVE "F$",TTXT,A8192,L"X-8192
There are better ways to do this, but this program will work on any valid text
file that is smaller than 16K. What it does is clear the two hi-res screens
(which is 16K of memory) and load the text file there. Since text files aren't
supposed to contain any CHR$(0)'s except at the end, we scan the file replacing
CHR$(13) (unix newline characters) with CHR$(10) (apple return characters)
until we see a CHR$(0) -- which means we've run off the end of the file and
into the 0's left by the HGR:HGR2 commands. The location at which that happens
tells us how long the file is, so we know how much data to write back when we
save it again. It's possible to fetch the length directly, but I can never
remember the magic numbers so this will have to do.
Todd Whitesel
toddpw @ ugcs.caltech.edu