Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10 UW 5/3/83; site uw-beaver
Path: utzoo!watmath!clyde!burl!ulysses!mhuxl!houxm!houxz!vax135!cornell!uw-beaver!info-mac
From: info-mac@uw-beaver (info-mac)
Newsgroups: fa.info-mac
Subject: Re: File usage in MacPascal
Message-ID: <1535@uw-beaver>
Date: Tue, 21-Aug-84 22:06:08 EDT
Article-I.D.: uw-beaver>.1535
Posted: Tue Aug 21 22:06:08 1984
Date-Received: Thu, 23-Aug-84 00:16:11 EDT
Sender: daemon@uw-beave
Organization: U of Washington Computer Science
Lines: 82

From: Stuart Reges 
I run the intro Pascal courses at Stanford, so I am looking at MacPascal as
well.

I have been playing with external files in MacPascal and find they pretty much
do the right thing.  Files created by one program can be read as data for other
programs, even non-TEXT files.  The only trick involved in creating external
files is to give a name to the file when using RESET or REWRITE, as in:

	rewrite (outfile, 'stuff');
	reset (infile, 'stuff');

MacPascal doesn't like you to reassign OUTPUT.  It is possible to do so,
however, if you first CLOSE it:

	close (output);
	rewrite (output, 'stuff');

Apparently it assigns OUTPUT to the TEXT window, so you have to undo this
first.  The final release might not require this kludge.

One nice file demo I like is to have a structure like this:

	type person = RECORD
		name: string;
		age : integer;
		sex : CHAR;
	     end;
	var f: file of person;

And then to use the Observe window to watch f^.name, f^.age and f^.sex as you
do a series of GETs on a file you have created.  There are a few minor bugs in
the beta release, but I expect these will be fixed.

About printing, there is nothing really difficult about it, so I'm not sure why
there is no facility for it.  For some reason I had taken this for granted up
to now.  The documentation for the beta release makes no mention of it and
there seems to be no facility for doing it directly.

I have four suggestions.  Here they are, ranked from worst to best:

	o You can generate an external file and then use MacPascal to OPEN it
	  and PRINT it.  The problem is that it tries to format it as a
	  program.  

	o You can generate an external file and then use MacWrite to OPEN it
	  and PRINT it.  This requires many disk swaps if you have only one
	  drive.

	o You can directly assign the output channel to the printer by saying
	  something like:

			rewrite (outfile, 'printer:');

	  or, as explained above, if you are using OUTPUT you can use this
	  kludge:

			close (output);
			rewrite (output, 'printer:');

	o You can generate an external file and then use the following program
	  in MacPascal to print it:

		program Print (input, output);
		var FileName, OneLine: string;
		    infile, outfile  : text;
		begin
		    write ('File to print? ');
		    readln (FileName);
		    reset (infile, FileName);
		    rewrite (outfile, 'printer:');
		    while not eof (infile) do begin
			readln (infile, OneLine);
			writeln (outfile, OneLine);
		    end;
		    writeln ('All done now.');
		end.

I haven't actually tested the last two of these because I don't have a printer
handy.  I will test them tonight and let you know.  I'm pretty sure they work,
though, because there seems to be a device called "PRINTER:".
-------