Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.2 (Tek) 9/28/84 based on 9/17/84; site dadla.UUCP
Path: utzoo!watmath!clyde!cbosgd!ihnp4!mhuxn!mhuxr!mhuxt!houxm!vax135!cornell!uw-beaver!tektronix!teklds!dadla!jamesp
From: jamesp@dadla.UUCP (Jim Perkins)
Newsgroups: net.micro.apple
Subject: Re: ProDOS READ/WRITE GET/PRINT?
Message-ID: <419@dadla.UUCP>
Date: Tue, 17-Sep-85 14:54:01 EDT
Article-I.D.: dadla.419
Posted: Tue Sep 17 14:54:01 1985
Date-Received: Thu, 19-Sep-85 06:25:21 EDT
References: <141@pyuxv.UUCP>
Reply-To: jamesp@dadla.UUCP (Jim Perkins)
Organization: Jupiter Phase, Beaverton, OR
Lines: 108

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