craig@pyuxv.UUCP (09/12/85)
In Applesoft BASIC on my Apple //eE (ProDOS 1.1.1) I have been unsuccessfully trying to read TXT characters from one Disk file apply a little logic, and write the transliterated characters to another Disk file. What's the glitch? For example: [D$ = CHR$(4)] PRINT D$;"OPEN <in file>" PRINT D$;"READ <in file>" GET C$ [check and possibly translate] PRINT C$; [loop back to GET until EOF] [on EOF CLOSE file(s)] The above works as expected; prints the TXT file to the screen just fine. If PRINT D$;"OPEN <out file>" PRINT D$;"WRITE <out file>" is added ahead of the GET statement, the program only responds to C$'s entered on the keyboard. It's as if the OPEN/READ, which previously worked, is ignored due to the addition of OPEN/WRITE. Characters entered on the keyboard are buffered and eventually written to the <out file>. I have seen no prohibition of this READ/WRITE GET-PRINT in the manuals. Am I missing a simple workaround, short of Assembler routine(s). It's not another bug in ProDOS, surely. - - - - - - - - - - - - - - - - - - - - - - - ..!ihnp4!pyuxv!craig (RB Craig @ Bell Communications Research) Piscataway, NJ 08854-1300 If you don't like what you see, you may need to learn to like more things.
jamesp@dadla.UUCP (Jim Perkins) (09/17/85)
In article <141@pyuxv.UUCP> craig@pyuxv.UUCP writes: >In Applesoft BASIC on my Apple //eE (ProDOS 1.1.1) >I have been unsuccessfully trying to read TXT characters >from one Disk file apply a little logic, and write the >transliterated characters to another Disk file.... You should be aware that DOS (whether it is 3.3 or ProDOS) only knows how to perform an operation on one file at a time, although you can have as many open files as the DOS MAXFILES command allows. Example: Read in 100 characters from F1$, transform, and write to F2$, where F1$="INFILE.TXT" and F2$="OUTFILE.TXT", or any other strings that turn you on. This works because DOS only knows how to "WRITE" until another DOS command comes along. Likewise, DOS only knows how to "READ" until another DOS command comes along. . . . 1000 REM READ & TRANSFORM 1005 D$ = CHR$(4) 1100 REM OPEN FILES 1105 PRINT D$; "OPEN "; F1$ 1110 PRINT D$; "OPEN "; F2$ 1200 REM READ, XFORM, & WRITE 1210 FOR I = 1 TO 100 1220 PRINT D$; "READ "; F1$: REM THIS NEGATES ANY PRIOR READ OR WRITE STATEMENT 1230 GET C$ 1240 GOSUB 2000: REM TRANSFORM C$ 1250 PRINT D$; "WRITE "; F2$: REM THIS NEGATES ANY PRIOR READ OR WRITE STATEMENT 1260 PRINT C$; 1270 NEXT I 1280 PRINT D$; "CLOSE "; F1$ 1290 PRINT D$; "CLOSE "; F2$ . . . 2000 REM TRANSFORM C$ . . . 2099 RETURN . . . Another Example: Read in 100 characters from F1$, transform, and write to F2$, All the time writing to the screen what is coming from F1$ where F1$="INFILE.TXT" and F2$="OUTFILE.TXT", or any other strings that turn you on. Note that this means we must "turn off" DOS output by printing a "null DOS command", a lone CHR$(4). . . . 1000 REM READ & TRANSFORM 1005 D$ = CHR$(4) 1100 REM OPEN FILES 1105 PRINT D$; "OPEN "; F1$ 1110 PRINT D$; "OPEN "; F2$ 1200 REM READ, XFORM, & WRITE 1210 FOR I = 1 TO 100 1220 PRINT D$; "READ "; F1$: REM THIS NEGATES ANY PRIOR READ OR WRITE STATEMENT 1230 GET C$ 1232 PRINT D$: REM THIS NEGATES ANY PRIOR READ OR WRITE STATEMENT 1234 PRINT C$;: REM PRINT INPUT CHARACTER ON SCREEN 1240 GOSUB 2000: REM TRANSFORM C$ 1250 PRINT D$; "WRITE "; F2$: REM THIS NEGATES ANY PRIOR READ OR WRITE STATEMENT 1260 PRINT C$; 1270 NEXT I 1280 PRINT D$; "CLOSE "; F1$ 1290 PRINT D$; "CLOSE "; F2$ . . . 2000 REM TRANSFORM C$ . . . 2099 RETURN . . . Hope this answers your question! -- \ | / James T. Perkins \ | / "Roads? Where we're =========================================== O - - - going we don't NEED tektronix!dadla!jamesp / | \ Roads..." / | \ A.A.A.A.A.: An organization for drunks who drive