home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / PASSRC.ZIP / LIST.PAS < prev    next >
Pascal/Delphi Source File  |  1991-02-04  |  3KB  |  99 lines

  1.                                          (* Chapter 16 - Program 6 *)
  2. program List_Pascal_Source_Files;
  3.  
  4. (* This program can be used to list programs written in any language
  5.    on the line printer.  It will list the filename, the latest date
  6.    and time when the file was modified, and the contents with line
  7.    numbers.  If there are more than 70 characters on any line, the
  8.    remaining characters will be spilled to the next line.  To space
  9.    the paper up, a formfeed is used.                               *)
  10.  
  11. Uses Printer, Dos;
  12.  
  13. const Max_Lines_Per_Page = 55;
  14.  
  15. type Command_String = string[127];
  16.  
  17. var Input_File      : text;
  18.     Input_Line      : string[140];
  19.     Line_Number     : integer;
  20.     Lines_Printed   : integer;
  21.     Page_No         : integer;
  22.     Index           : integer;
  23.     Filename        : Command_String;
  24.     Date            : DateTime;
  25.  
  26.  
  27. procedure Initialize; (* ****************************** initialize *)
  28. var Time_And_Date : longint;
  29. begin
  30.    if ParamCount = 1 then
  31.       Filename := ParamStr(1)
  32.    else begin
  33.       Write('Enter filename ----> ');
  34.       Readln(Filename);
  35.    end;
  36.    Assign(Input_File,Filename);
  37.    Reset(Input_File);
  38.    Line_Number := 1;
  39.    Lines_Printed := 66; (* This is to force a header immediately *)
  40.    Page_No := 1;
  41.    GetFTime(Input_File, Time_And_Date);
  42.    UnpackTime(Time_And_Date, Date);
  43. end;
  44.  
  45.  
  46. procedure Read_A_Line; (* *************************** read a line *)
  47. begin
  48.    for Index := 1 to 140 do Input_Line[Index] := ' ';
  49.    Readln(Input_File,Input_Line);
  50. end;
  51.  
  52.  
  53. procedure Format_And_Print; (* ****************** format and print *)
  54. var Line_Length : byte;
  55. begin
  56.    Write(Lst,Line_Number:6,'  ');
  57.    Line_Length := 0;
  58.    for Index := 1 to 140 do begin
  59.       if Input_Line[Index] <> ' ' then Line_Length := Index;
  60.    end;
  61.    for Index := 1 to Line_Length do
  62.       Write(Lst,Input_Line[Index]);
  63.    Writeln(Lst);
  64.    Lines_Printed := Lines_Printed + 1;
  65.    Line_Number := Line_Number + 1;
  66. end;
  67.  
  68.  
  69. procedure Check_For_Page; (* ********************** check for page *)
  70. begin
  71.    if Lines_Printed > Max_Lines_Per_Page then begin
  72.       if Page_No > 1 then
  73.          Writeln(Lst,Char(12));
  74.       Writeln(Lst);
  75.       Write(Lst,'     ');
  76.       Write(Lst,'Source file --->',Filename:13);
  77.       Write(Lst,Date.Month:5,'/',Date.Day:2,'/',Date.Year:2);
  78.       Write(Lst,Date.Hour:5,':',Date.Min:2,':',Date.Sec:2);
  79.       WriteLn(Lst,'   Page':10,Page_No:4);
  80.       Writeln(Lst);
  81.       Write('Source file --->',Filename:12);
  82.       Writeln(' page':12,Page_No:4);
  83.       Page_No := Page_No + 1;
  84.       Lines_Printed := 1;
  85.    end;
  86. end;
  87.  
  88.  
  89. begin  (* ******************************************* main program *)
  90.    Initialize;
  91.    Check_For_Page;
  92.    repeat
  93.       Read_A_Line;
  94.       Format_And_Print;
  95.       Check_For_Page;
  96.    until Eof(Input_File);
  97.    Writeln(Lst,Char(12));
  98. end.  (* of main program *)
  99.