home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / modula2 / compiler / fst_mod / source / printfle.mod < prev    next >
Text File  |  1987-02-08  |  1KB  |  44 lines

  1.                                          (* Chapter 8 - Program 5 *)
  2. MODULE PrintFle;
  3.  
  4. FROM FileSystem IMPORT Lookup, Close, File, Response, ReadChar,
  5.                        WriteChar;
  6. FROM InOut      IMPORT Write, WriteString, ReadString, WriteLn;
  7.  
  8. VAR  NameOfFile : ARRAY[1..15] OF CHAR;
  9.      InFile     : File;
  10.      OutFile    : File;
  11.      CapFile    : File;
  12.      PrtFile    : File;
  13.      Character  : CHAR;
  14.  
  15. BEGIN
  16.    REPEAT                  (* repeat until a good filename is found *)
  17.       WriteLn;
  18.       WriteString("Enter name of file to display,");
  19.       WriteString(" store, and print ---> ");
  20.       ReadString(NameOfFile);
  21.       Lookup(InFile,NameOfFile,FALSE);
  22.    UNTIL InFile.res = done;                  (* good filename found *)
  23.  
  24.    Lookup(OutFile,"ANYNAME.TXT",TRUE);
  25.    Lookup(CapFile,"CAPSONLY.TXT",TRUE);
  26.    Lookup(PrtFile,"PRN",TRUE);
  27.  
  28.    WriteLn;
  29.    REPEAT       (* character read/display loop - quit at InFile.eof *)
  30.       ReadChar(InFile,Character);
  31.       IF NOT InFile.eof THEN
  32.          Write(Character);
  33.          WriteChar(OutFile,Character);
  34.          WriteChar(CapFile,CAP(Character));
  35.          WriteChar(PrtFile,Character);
  36.       END;
  37.    UNTIL InFile.eof;                      (* quit when eof is found *)
  38.    Close(InFile);
  39.    Close(OutFile);
  40.    Close(CapFile);
  41.    Close(PrtFile);
  42.  
  43. END PrintFle.
  44.