[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
2 Applesoft BASIC questions/1 Hyper C question
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?
So then, I figured "Hey, maybe I can just load the file directly into memory
and make the control-J replacements with PEEKs and POKEs." But when I
typed "BLOAD XAA,A$2000,TTXT" I got "NO BUFFERS AVAILABLE". I even tried
rebooting the disk and making this the first command I entered upon starting
BASIC, but to no different effect. How can I be out of memory before even
doing anything?
Finally, I remembered Hyper C. I was stopped short before getting anywhere,
though, since I couldn't get the most rudimentary file I/O to work. Can
anyone familiar with Hyper C tell me what's wrong with the following program,
which doesn't do a damn thing?
#include <std.h>
main()
{
FILE *a;
int i;
create(a,"THISFILE",0);
fprintf(a,"Hello world!\n");
}
I later tried putting the create() inside a printf() to see the return value,
which turned out to be -1; according to the documentation, this means that the
file was created successfully. After executing the program, though, no new
file was to be found. Help!
A quick blast from the past: I was watching Monday's episode of "Automan" on
the Sci-Fi Channel, during which the following exchange took place between
Automan and his creator, Walter Nebuchar:
Automan: "When someone asks me what my sign is, what do I tell them?"
Walter: "...Tell them you're an Apple 2."
------------------------------------------------------------------------------
"Guess again, Dr. Lu! Your plot flopped! Fizzled! Because of YOU!"
"Im-impossible! You were brainwashed! HOW could *I* fail?" | smmcafee@mtu.edu
"Because you're a SCIENTIST who FORGOT she's ALSO a WOMAN!" | Sean McAfee
-- from "The Flash" #200, 9/70