Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!rochester!cornell!uw-beaver!tektronix!tekgen!tekigm2!timothym From: timothym@tekigm2.TEK.COM (Timothy D Margeson) Newsgroups: comp.lang.pascal Subject: Re: turbo & byte-reading Message-ID: <2047@tekigm2.TEK.COM> Date: Tue, 11-Aug-87 14:04:18 EDT Article-I.D.: tekigm2.2047 Posted: Tue Aug 11 14:04:18 1987 Date-Received: Thu, 13-Aug-87 07:03:45 EDT References: <353@nysernic> Reply-To: timothym@tekigm2.UUCP (Timothy D Margeson) Organization: Tektronix, Inc., Beaverton, OR. Lines: 87 Hi, For most small applications, the following code should do the trick, however if you need to read large amounts of data, a different approach is needed, using pointers to arrays of chars as row and column designators as an example. ============================== BEGIN FILEIO.PAS ================================ {$R+}{Enable array bounds checking} const MaxChar = 2000; {this must be integer} {there are tricks you must do if you need more than 32,768 characters} type FileSpec = string[13]; TypeChar = char; var Error : boolean; InChar : array[1..MaxChar] of char; InFile : file of char; InName : FileSpec; CharCounter : real; I,J,K : integer; procedure Open1(InputFileName:FileSpec;var Error:boolean); begin Error:=false; assign(InFile,InputFileName); {$I-}reset(InFile){$I+}; Error:=IOResult<>0; end; procedure Usage; begin writeln('FILEIO - A program to read a graphics file by character -'); writeln(' '); writeln(' Usage: fileio '); writeln(' '); end; {================================ MAIN ======================================} begin LowVideo; writeln; if ParamCount=0 then Usage else begin case Paramcount of 1 : begin InName:=ParamStr(1); end; else begin writeln('Too many arguments in command line!'); HALT end end; {case} begin for I:=1 to ord(InName[0]) do InName[I]:=upcase(InName[I]); Open1(InName,Error); if not Error then begin I:=1; while (not EOF(InFile)) and (I