[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: 2 Applesoft BASIC questions/1 Hyper C question
In article <9406081756.AA25635@phy.mtu.edu>,
Sean M. McAfee <smmcafee@phy.mtu.edu> wrote:
>Criminy, I hope someone can help me. I'm at my wit's end.
>
>Last month, as graduation approached, I faced the impending deactivation of
>my account. I had a few large files of saved Usenet articles, and I didn't
>have the time to go through them and select which ones I wanted to keep. So,
>I chopped the largest file up with "split", downloaded all the pieces to my
>GS, and combined them with GSHK.
>
>Recently, I un-shrunk the first of the pieces, and found that, somehow, all
>of the carriage returns (control-M's) in the file had been turned into
>control-J's. How to reverse the change? Since I don't (yet) have any kind
>of programming shell, and since none of the text editors I have can replace
>text with a control-M, I tried Applesoft BASIC first:
>
> 5 ONERR GOTO 100
> 10 D$ = CHR$ (4)
> 20 PRINT D$;"OPEN XAA"
> 30 PRINT D$;"READ XAA"
> 40 PRINT D$;"OPEN XAA2"
> 50 PRINT D$;"WRITE XAA2"
> 60 GET A$
> 70 IF A$ = CHR$ (10) THEN PRINT : GOTO 60
> 80 PRINT A$;
> 90 GOTO 60
> 100 PRINT D$;"CLOSE"
> 110 END
>
>The program didn't work, and subsequent fiddling showed that the second OPEN
>seemed to cancel the first one. Why did it do this? I checked my copy of
>"The ProDOS Handbook" by Rice and Rice, and it says: "Under ProDOS a program
>can have up to eight files open at the same time...ProDOS automatically assigns
>a 1024-byte buffer to each standard file when it is opened." So what the
>#$^&*# am I doing wrong?
You have to open both files, as you did, early in the program, but the
read and write commands cancel each other out. Only one can be active
at a time. Therefore, you have to reissue the read and write commands
each time you change files, or change from reading to writing, or
vice versa. Try this one:
5 ONERR GOTO 100
10 D$ = CHR$ (4)
20 PRINT D$;"OPEN XAA"
30 PRINT D$;"OPEN XAA2"
40 PRINT D$;"READ XAA"
50 GET A$
60 PRINT D$;"WRITE XAA2"
70 IF A$ = CHR$ (10) THEN PRINT : GOTO 40
80 PRINT A$;
90 GOTO 40
100 PRINT D$;"CLOSE"
110 END
I'm guessing that you got the 'NO BUFFERS AVAILABLE', because the file
you tried to bload was too large to fit into available RAM, above
where you loaded it. If it's close, you might be able to load it
a little lower than $2000, but be careful, I think applesoft keeps
your program starting at $0800. This small program won't use up
that much ram, so you can use some of it's space.
The program above should work, I do quick file hacks like that
all the time. BASIC is great for this kind of stuff. Good luck.
--
___________________________________________________________________________
|___ Chris Deschu cdeschu@nyx.cs.du.edu
_|_|con (610)791-3596 4804 Bowood Street, Center Valley, PA. 18034-9628
:-)|echnologies is IT in the Lehigh Valley for Apple ][ Consulting & Repair