[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: 2 Applesoft BASIC questions/1 Hyper C question
David Empson (dempson@actrix.gen.nz) wrote:
: In article <9406081756.AA25635@phy.mtu.edu>,
: Sean M. McAfee <smmcafee@phy.mtu.edu> wrote:
: As others have explained, the problem with your BASIC program is that
: the READ and WRITE commands are cancelled by the next DOS command.
: You could do a loop which does a READ, then GETs a byte, then does a
: WRITE, then PRINTs a byte, but it would be horribly slow.
: A slight improvement would be to do a READ, then use GET to fill a
: string or array, then WRITE and PRINT it to the destination file.
: A still better method follows.
......stuff deleted.....
: What you could do is BLOAD the file in small chunks, patch the chunk,
: then write it out to another file. The following fragments of a BASIC
: program demonstrate the principle. I'm assuming that you know the
: name of the file in advance.
..... lengthy procedure deleted....
An alternative is to use the Proton Language, which designed to handle
file manipulation tasks like this. A task to convert ^J to Prodos carriage
returns might look like:
Array Byte Line 255
Integer Ref1, Ref2
Start
Open @Parm[1],Page[4,0],Ref1
Open @Parm[2],Page[4,0],Ref2
NewLine Ref1, 10, 255 {tell prodos that ^J is "new line"}
InpFile Ref1
OutFile Ref2
Loop
InpStr Line,255
Exit DosErr > 0
OutStr Line
OutChar 13 {after each line, output real "new line" character}
Continue
Close Ref1
Close Ref2
Stop
In this implementation, the file names are entered as parameters
when the program is invoked.