home *** CD-ROM | disk | FTP | other *** search
- program ProgList;
- {$B-}
- {$U-}
- (********************************************************************
- * Program Lister Version 1.00 *
- * by Donald Gloistein, 1986 *
- ********************************************************************
-
-
- INSTRUCTIONS : type PROGLIST ? <CR> to see the help menu with defaults.
-
- This is the first draft version. Please give me feedback on what would
- be more convenient in the program.
-
- **************************************************************************
- Written by Don Gloistein , 1986
- Telephone: 713-331-9372
- CIS : 76010,474
- Addrress : 2500 Fairway Dr. #922
- Alvin, TX 77511
-
- This program is released to public domain for personal, non-
- commercial use ONLY. You may use it yourself, give it to your
- friends, or distribute it for a cost-based fee as part of a user's
- group or bulletin board service.
-
- As this is just a first draft program, it needs more features and
- the ability to do more sophisicated printing. When I have added all
- of that, I feel I will be out of the realm of editing existing work
- and into a new program.
- ********** A Unique ShareWare, Money or Help Me Improve the Program *****
- If you ask for support or updates of this program, please expect
- to make a donation. This donation is either in the form of money or
- sweat. If you are a programmer like me, you like to improve programs
- and make them more useful. You teach me, that is worth money to me.
- If this program is of use to you please consider a donation of $10.00.
- OR
- Contribute Ideas:
- As the program and source is fleshed out, only the compiled version and
- the instalation programs will be given out. The source code will be
- shared with those who help with suggestions and programming hints.
-
- Compiled on Turbo Pascal ver 3.01A and MS-Dos.
- ***********************************************************************
- Some routines may be Dos specific, please check.
- These include the opening of the 'PRN' file and the MSDOS specific
- cursor control. These are easy to change. Global change of the
- OutFile to lst will make it print to the printer. However, there
- would be no ability to print to a file. I don't know the way to
- declare it in CP/M, so I hope the change is superficial. I wanted
- to avoid testing each Write statement against the PrintFile variable.
- Otherwise, I am trying to write with the least amount of problems.
- CAUTION: the Modify.Pas procedure (SaveDef.inc) works only for MSDOS
- Turbo 3.01A. The file date and time functions (FDTTM.INC) work with
- MSDOS 3.01A. They use file handles, these could be changed for other
- versions, with little trouble.
- *************************************************************************)
-
-
- { ***********************Declarations ************************* }
-
- Const
- Version = 'ProgList 1.00';
- CopyRight = 'Copyright 1986, Don Gloistein';
- Compiled = '11/08/86 13:04:00';
- VidInt = $10;
- SetCurFunct = $100;
- GetCurFunct = $300;
- MaxLine = 255;
- PathLength = 80;
- FormFeed = #12;
- lfcr =#13#10;
- (*
- {Use if including Modify.inc otherwise comment out}
- {SaveDef error Constants}
- Err0 = ' : Was modified successfully.';
- Err1 = ' : Must be in logged directory.';
- Err2 = ' : Error reading.';
- Err3 = ' : Error writing.';
- Err4 = ' : No error msg.';
- Err5 = ' : Wrong Version or .COM file.';
- Err : array[0..5] of string[40] = (Err0,Err1,Err2,Err3,Err4,Err5);
- (**)
-
- type
- PrtCtl = (PrtInit,BoldOn,BoldOff,UndOn,UndOff,ExpandOn,ExpandOff,
- CondOn,CondOff,PitchOne,PitchTwo,PrtEnd);
- PrtOut = array[0..10] of byte;
- const
- (* Typed constants will be used for the modify.inc procedure *)
- VerCheck : string[14] = Version; {Beginning of constants must remain}
- ProgName : string[12] = 'PROGLIST.COM'; {Name used to find this program }
- ProgPath : string[64] = '' ; {Path this program is in}
- DefExt : string[4] = '.PAS'; {Insert changable constants here}
- IncDefExt: string[4] = '.PAS'; {May be set different for C lang}
- QuickList : boolean = False; {Just list functions & procedures}
- PageFeed : boolean = False; {New Page for include files}
- Banner : boolean = True; {Main File Banner}
- FirstFeed : boolean = False; {Start with form feed}
- EndFeed : boolean = True; {End listing with form feed}
- MainHeader : boolean = False; {Print upto the first procedure}
- IncludePrint : boolean = True; {Print include files}
- TabExpand : boolean = False; {Filters line, slows it down}
- PageWidth : integer = 80;
- PrintLength : integer = 55; {Banners are included in count}
- VerticalTabLength : integer = 3; {To give upper page white space}
- HorizTabLength : integer = 2; {Set for Pascal Listings, only used}
- { if TabExpand is true}
- { My printer does not expand tabs}
- RightMargin : integer = 0;
- MaxColCheck : integer = 20; {Value to avoid GetWord obtaining}
- {an Op word that was a parameter }
- PrintFile : boolean = True; {originally to test without using}
- {the printer, left it in for quick}
- {listings}
- { Beginning of the Byte Arrays for Printer Strings.}
- PrtStr: array[PrtCtl] of PrtOut =
- (($FF,0,0,0,0,0,0,0,0,0,0),
- ($FF,0,0,0,0,0,0,0,0,0,0),
- ($FF,0,0,0,0,0,0,0,0,0,0),
- ($FF,0,0,0,0,0,0,0,0,0,0),
- ($FF,0,0,0,0,0,0,0,0,0,0),
- ($FF,0,0,0,0,0,0,0,0,0,0),
- ($FF,0,0,0,0,0,0,0,0,0,0),
- ($FF,0,0,0,0,0,0,0,0,0,0),
- ($FF,0,0,0,0,0,0,0,0,0,0),
- ($FF,0,0,0,0,0,0,0,0,0,0),
- ($FF,0,0,0,0,0,0,0,0,0,0),
- ($FF,0,0,0,0,0,0,0,0,0,0));
- {**** End of Printer Strings. ****************** }
- Tail : byte = 0; {End of constants must remain this way}
-
- Keyword : Array[1..3] of String[10] = ('PROCEDURE','FUNCTION','OVERLAY');
- Optword : Array[1..4] of String[10] = ('BEGIN','TYPE','CONST','VAR');
- ChangeName: boolean = False;
- digit : set of char = ['0'..'9'];
- PrintChar: set of char = [' '..'}'];
- LineOfSpace: string[80] =
- ' ';
- {80 initialized spaces}
- LnRdCount: integer = 0;
- LnPrtCount: integer = 0;
- InitCurs: integer = 0;
- Type
- WorkString = String[MaxLine];
- FileName = String[PathLength];
- fvar = text[$4000];
- BannerStr = String[MaxLine];
- Var
- CurRow : integer;
- PageNum: integer;
- LoHiVid: Boolean; {True if low video}
- MainFileName: FileName;
- OutPutName: FileName;
- MainFile: fvar;
- OutFile: fvar; {Used for output file}
- Usage :string[80] ;
- IncBannerStr : BannerStr;
- MainBannerStr : BannerStr;
- CurBanner : ^BannerStr;
- search1,search2,search3,search4: string[5];
- DoSave: boolean;
- Count, Count1 : Integer;
- regs: record
- case integer of
- 1: (AX, BX, CX, DX, BP, SI, DI, DS, ES, Flags: Integer);
- 2: (AL, AH, BL, BH, CL, CH, DL, DH: Byte)
- end;
-
- { ************************* End of declarations *************** }
-
- {$I FDTTM.INC}
- {$I SAVEDEF.INC}
-
- Procedure PrintTitle; { Prints the Program Title}
- begin
- writeln(Version,lfcr,CopyRight,lfcr,Compiled);
- end; {PrintTitle}
-
-
- Procedure PrintBanner(page:Integer);
- { prints current banner string}
- var
- I,J : Integer;
- temp: string[MaxLine];
- pgstr: string[4];
- begin
- str(page:3,pgstr);
- temp := '>> '+ CurBanner^ + ' Page: '+ pgstr + ' <<';
- j := ((PageWidth - length(temp)) div 2) -2 ;
- for I := 1 to J do
- insert(#32,temp,1);
- writeln(OutFile,temp,lfcr);
- CurRow := CurRow +2;
- end;
-
- Procedure MakeBanner(var Str: BannerStr;var f: fvar;fname:FileName);
- begin
- str := Fname + ' Last Change: '+ ftime(f) + ' on '+ fdate(f) ;
- End;
-
-
- Procedure readline(VAR f : fvar; var nl : WorkString);
- {read a line from the file and expand tabs into supplied string}
- {if TabExpand is True, this routine signif. slows processing}
- var
- I,O,J : Byte;
- TempBuff: workstring;
- Len : byte absolute TempBuff;
- begin
- LnRdCount := succ(LnRdCount);
- GoToXy(56,1);
- Write(LnRdCount);
- Readln(f, nl);
- if not TabExpand then exit
- else move(nl[0],TempBuff[0],ord(nl[0])+1);
- I := 1;
- O := 0;
- while I <= Len do begin
- if TempBuff[I] = #9 then begin {expand tabs}
- O := succ(O);
- J := 1;
- while (J mod HorizTabLength) <> 0 do
- J := succ(J);
- move(LineOfSpace[1],nl[O],J);
- O := O + J -1;
- end else begin {insert regular character}
- if TempBuff[I] in PrintChar then {filter characters}
- begin
- O := succ(O);
- nl[O] := TempBuff[I];
- End;
- END;
- I := succ(I);
- END;
- {set length of nl}
- nl[0] := Chr(O);
- END; {readline}
-
-
- Procedure UpCaseStr(Var S :workstring);
- {Makes string UpperCase, relax V if parameter is not WorkString}
-
- Var
- I : Integer;
- begin
- For I := 1 to Length(S) do
- S[I] := UpCase(S[I]);
- end;
-
- Function KeyCheck(KW : WorkString) : Boolean;
- var
- I : Integer;
- begin
- KeyCheck := False;
- UpCaseStr(KW);
- For I := 1 to 3 do
- if KW = Keyword[I] then
- KeyCheck := True;
- end; {KeyCheck}
-
- Function Optword_Check(KW : WorkString) : Boolean;
- {Returns True if the word is in the Keyword string}
-
- var
- I : Integer;
- begin
- Optword_Check := False;
- UpCaseStr(KW);
- For I := 1 to 4 do
- if KW = Optword[I] then
- OptWord_Check := True;
- end;
-
- Procedure GetFirstWord(PassedText : WorkString; Var First : WorkString);
- Var
- J : byte;
-
- begin
- move(PassedText[0],First[0],ord(PassedText[0])+1);
- J := 0;
- while (First[1]= #32 ) and (First[0] <> #0) do
- if (succ(J) <> MaxColCheck) then {Try to avoid false procedures}
- delete(First,1,1); {careful that we don't get an endless loop}
- J := pos(#32,First);
- if (J <> 0) then
- First[0] := chr(J-1); {else a null or full word already}
- End; {GetFirstWord}
-
- function GetCursSize: integer;
- begin
- Regs.AX := GetCurFunct;
- Intr(VidInt,Regs);
- GetCursSize := Regs.CX;
- end; { GetCursSize }
-
- procedure SetCursorMode(Size : integer);
- begin
- Regs.AX := SetCurFunct;
- Regs.CX := Size;
- Intr(VidInt,Regs);
- end; { SetCursSize }
-
-
- Procedure Initial;
- begin
- CurRow := 1;
- PageNum:= 1;
- InitCurs := GetCursSize;
- SetCursorMode($0F0F);
- IncBannerStr :='';
- MainBannerStr := '';
- Regs.ah := 8;
- Regs.bh := 0;
- Intr(16, Regs);
- LoHiVid := ((Regs.al and 8) = 0 );
- Usage := copy(ProgName,1,(pos('.',ProgName)-1));
- Usage := Usage + ' [?]|[MainFileName [OutFileName]] [-|/]I Q P B F M R# W# V# H# L# /S[X]';
- clrscr;
- PrintTitle;
- MainFileName := '';
- OutPutName := '';
- search1 := '{$I'; { These assignments are now safe, checks }
- search2 := '{$i'; { were placed in the Include file logic }
- search3 := '(*$I'; { for examples and string assignments }
- search4 := '(*$i';
- DoSave := False;
- end {initial};
-
- procedure videxit;
- begin
- if LoHiVid then
- LowVideo
- else
- HighVideo;
- SetCursorMode(InitCurs);
- halt;
- End;
-
-
- Function Open(var fp:fvar; name: Filename): boolean;
- begin
- Assign(fp,Name);
- {$I-}
- reset(fp);
- {$I+}
- If IOresult <> 0 then
- begin
- Open := False;
- close(fp);
- end
- else
- Open := True;
- end { Open };
-
- Procedure Tell_Usage;
- Begin
- writeln(Usage,lfcr);
- VidExit
- End;
-
- Procedure GetOutPutName;
- var
- TempStr: FileName;
-
- begin
- if OutPutName <> '' then exit;
- GotoXy(1,10);
- Write('File to Print to? : ');
- ReadLn(OutPutName);
- GoToXy(1,10);
- ClrEol;
- End; {GetOutPutName}
-
- Procedure GetNewName;
- var
- TempStr: FileName;
- TempStr2:FileName;
- Ch : Char;
- Begin
- Writeln(lfcr,'This will change the default Name or Path for the program:');
- Writeln(lfcr,' Current ProgName : ',ProgName);
- Write( 'Enter new one or <ENTER>: ');
- ReadLn(TempStr);
- if (TempStr <>'') and (Ord(TempStr[0]) <= 8) then
- begin
- {$V-}
- UpCaseStr(TempStr);
- {$V-}
- if pos('.',TempStr) = 0 then
- TempStr := TempStr + '.COM';
- end
- else
- TempStr := ProgName;
- WriteLn(lfcr,' Current Path : ',ProgPath);
- Write( 'Enter new one or <ENTER>: ');
- ReadLn(TempStr2);
- {$V-}
- UpCaseStr(TempStr2);
- {$V+}
- if (TempStr2[ord(TempStr2[0])] <> '\') then
- if (ord(TempStr2[0]) <>0) then
- TempStr2 := TempStr2 + '\';
- Writeln(lfcr,'New Name and Path : ',TempStr2 + TempStr);
- Write( ' Is this correct? <Y,N> ');
- read(kbd,Ch);
- Writeln(Ch);
- if UpCase(Ch) = 'Y' then
- begin
- ProgPath := TempStr2;
- ProgName := TempStr;
- End
- else
- begin
- Writeln(lfcr,' >> NO CHANGES MADE <<');
- VidExit;
- End;
- End; {GetNewName}
-
- Procedure Help;
- Begin
- Writeln(Usage);
- Writeln('Options:');
- Writeln(' /Q QuickList (just headings) default = ',QuickList);
- Writeln(' /A All Lines (NOT /Q) default = ',not QuickList);
- Writeln(' /I[+|-] List the Include files default = ',IncludePrint);
- Writeln(' /P[+|-] Page top for include files default = ',PageFeed);
- Writeln(' /F[+|-] Begin with form feed default = ',FirstFeed);
- Writeln(' /E[+|-] End with Form Feed default = ',EndFeed);
- Writeln(' /B[+|-] Print Banner type listing default = ',Banner);
- Writeln(' /M[+|-] Print Main file Header default = ',MainHeader);
- Writeln(' /T[+|-] Tab expansion (filters ^char) default = ',TabExpand);
- WriteLn(' /O[+|-|#] Output to file (# for prompt) default = ',PrintFile);
- Writeln(' /Rn Right Margin Indent to n default= ',RightMargin);
- Writeln(' /Wn Set page width to n default = ',PageWidth);
- Writeln(' /Vn Set Vert Tab to n default = ',VerticalTabLength);
- Writeln(' /Hn Set Horizontal tab to n default = ',HorizTabLength);
- Writeln(' /Ln Set Page number of lines to n default = ',PrintLength);
- Writeln(' /Daaa Main Default Extension to aaa default = ',DefExt);
- Writeln(' /Caaa Incl Default Extention to aaa default = ',IncDefExt);
- Writeln('Note: Default extension changes must be last or separate');
- Writeln(' /S[X] Set new Defaults and Save to ',ProgPath,ProgName);
- WriteLn(' X is used with /S to prompt for new Path and Name or default is used.');
- VidExit; {Note: This procedure does NOT return}
- End; {Help}
-
- Function Exist(var fn: FileName):Boolean;
- begin
- Assign(OutFile,fn);
- {$I-}
- Reset(OutFile);
- {$I+}
- Exist := (IOresult = 0);
- close(OutFile);
- end; {Exist}
-
- procedure ProcCommLine;
-
- Var
- Param: FileName;
- { ConfigName: FileName; } {Used for /SX and modify.inc}
- Loop,result,temp: Integer;
- I,J : Byte;
- numstr: string[4];
- tempstr: ^FileName;
- Ch: Char;
- Begin
- if ParamCount <> 0 then
- begin
- if (ParamStr(1) = '?') then
- Help;
- For Loop := 1 to ParamCount do
- Begin
-
- Param := ParamStr(Loop);
-
- While Param <> '' do
- Begin
-
- If (Param[1] in ['/','-']) {this is a parameter}
- Then
- Begin
- while (ord(Param[0]) >1) do
- Begin
- Case UpCase(Param[2]) of
- 'A': Begin
- quicklist := false;
- End;
- 'B': Begin
- if (Param[3] = '-') then
- Banner := False
- else
- Banner := True;
- End;
- 'C': Begin
- IncDefExt := copy(Param,3,3);
- insert('.',IncDefExt,1);
- Param := '';
- End;
- 'D': Begin
- DefExt := copy(Param,3,3);
- insert('.',DefExt,1);
- Param := '';
- End;
- 'E': Begin
- if (Param[3] = '-') then
- EndFeed := False
- else
- EndFeed := True;
- End;
- 'F': Begin
- if (Param[3] = '-') then
- FirstFeed := False
- else
- FirstFeed := True;
- End;
- 'H': Begin
- if (Param[3] in digit) then
- begin
- I :=3;
- while (Param[I] in digit) do
- I := succ(I);
- numstr := copy(Param,3,I -3);
- val(numstr,Temp,result);
- if (result <> 0) then
- writeln('I=',I,'/H Val error = ',result,' Str ',numstr)
- else HorizTabLength := Temp;
- end;
- End;
- 'I': Begin
- if (Param[3] = '-') then
- IncludePrint := False
- else
- IncludePrint := True;
- End;
- 'M': Begin
- if (Param[3] = '-') then
- MainHeader := False
- else
- MainHeader := True;
- End;
- 'O': Begin
- if (Param[3] = '-') then
- PrintFile := False
- else
- PrintFile := True;
- if (Param[3] = '#') then
- GetOutPutName;
- End;
- 'P': Begin
- if (Param[3] = '-') then
- PageFeed := False
- else
- PageFeed := True;
- End;
- 'Q': Begin
- QuickList := True;
- End;
- 'R': Begin
- if (Param[3] in digit) then
- begin
- I :=3;
- while (Param[I] in digit) do
- I := succ(I);
- numstr := copy(Param,3,I -3);
- val(numstr,Temp,result);
- if (result <> 0) then
- writeln('I=',I,'/L Val error = ',result,' Str ',numstr)
- else RightMargin := Temp;
- end;
- End;
- 'S': Begin
- DoSave := True;
- if UpCase(Param[3]) = 'X' then
- begin
- ChangeName := True;
- delete(Param,2,1);
- end;
- End;
- 'T': Begin
- if (Param[3] = '-') then
- TabExpand := False
- else
- TabExpand := True;
- End;
- 'V': Begin
- if (Param[3] in digit) then
- begin
- I :=3;
- while (Param[I] in digit) do
- I := succ(I);
- numstr := copy(Param,3,I -3);
- val(numstr,Temp,result);
- if (result <> 0) then
- writeln('I=',I,'/V Val error = ',result,' Str ',numstr)
- else VerticalTabLength := Temp;
- end;
- End;
- 'W': Begin
- if (Param[3] in digit) then
- begin
- I :=3;
- while (Param[I] in digit) do
- I := succ(I);
- numstr := copy(Param,3,I -3);
- val(numstr,Temp,result);
- if (result <> 0) then
- writeln('I=',I,'/W Val error = ',result,' Str ',numstr)
- else PageWidth := Temp;
- End;
- End;
- '?': Begin
- Help;
- End;
- Else Begin
- Writeln('Invalid option: ',Param[2],lfcr);
- Tell_Usage;
- End;
- End; {case}
-
- {Now Clean up parameter line}
- delete(Param,2,1); {remove first parameter letter}
- if (Param[2] in ['+','-','#']) then {remove + or -or #}
- delete(Param,2,1);
- {Remove any digits and check for length}
- { or else WILL GET INTO ENDLESS LOOP}
- while (Param[2] in digit )
- and (ord(Param[0]) <>1) do
- delete(Param,2,1);
- {Test if more parameter letters }
- if (ord(Param[0]) = 1) then
- Param :=''
- End; {while}
- End Else { If a parameter}
- Begin {this is a filename }
- If MainFileName = ''
- Then Begin
- MainFileName := Param;
- Param := '';
- End
- Else Begin { Two Files Entered on Command Line}
- if OutPutName = ''
- Then Begin
- OutPutName := Param;
- {$V-}
- UpCaseStr(OutPutName);
- {$V+}
- Param := '';
- PrintFile := True;
- if pos('.',OutPutName) = 0 then
- OutPutName := OutPutName + '.PRN';
- end
- else Begin
- Writeln('Error: Three Files listed!');
- Tell_Usage;
- End;
- End;
- End; {If a Parameter,else}
- End; {while}
- End; {for}
- End; {if paramcount not zero}
-
- if DoSave then
- Begin
- if ChangeName then GetNewName;
- I := SaveDef; {Comment out if you want to use Modify.Inc}
-
- (* ConfigName := ProgPath + ProgName; {set up file for modify}
- I := Modify( ConfigName,VerCheck,Tail); {comment out these two for }
- {SaveDef} *)
- clrscr;
- writeln(lfcr,ProgName,Err[I]);
- if I <> 0 then VidExit;
- writeln('New Defaults for ',ProgPath,ProgName,':');
- help;
- End;
- if Banner then {adjust so page doesnt double feed}
- PrintLength := PrintLength -4;
-
- If MainFileName = '' {make sure a filename was given}
- Then Begin
- GoToXy(1,10);
- ClrEol;
- Write('Enter Main Filename: ');
- readln(MainFileName);
- GoToXy(1,10);
- ClrEol;
- if (MainFileName = '') then
- begin
- Writeln(Usage,lfcr);
- VidExit;
- End;
- if (MainFileName = '?') then
- begin
- clrscr;
- help;
- end;
- End;
- {String declarations dont match}
- {$V-}
- UpCaseStr(MainFileName);
- {$V+}
- if (pos('.',MainFileName) = 0) then
- MainFileName := MainFileName + DefExt;
- If Not Open(MainFile,MainFileName) Then
- begin
- Writeln('ERROR -- File not found: ',MainFileName);
- VidExit;
- end;
- if PrintFile then
- begin
- if OutPutName = '' then
- begin
- OutPutName := MainFileName;
- delete(OutPutName,pos('.',MainFileName),4);
- OutPutName := OutPutName + '.PRN';
- end else
- if (pos('.',OutPutName) = 0 ) then
- OutPutName := OutPutName + '.PRN';
- if Exist(OutPutName) then
- begin
- GoToXy(1,10);
- clreol;
- write(OutPutName,' exists, replace? <Y,N> ');
- read(kbd,Ch);
- write(Ch);
- GoToXy(1,10);
- clreol;
- if UpCase(ch) = 'N' then
- VidExit;
- end;
- Assign(OutFile,OutPutName);
- {$I-}
- rewrite(OutFile);
- {$I+}
- If IOresult <> 0 then
- begin
- WriteLn('ERROR -- File not open: ',OutPutName);
- VidExit;
- End
- else begin
- GoToXy(1,7);
- Write('Writing to file: ',OutPutName);
- end;
- End else
- begin
- GoToXy(1,7);
- Assign(OutFile,'PRN');
- rewrite(OutFile);
- Write('Listing to Printer');
- end;
- End; {ProcCommLine}
-
- Procedure VerticalTab;
- var i: integer;
- begin
- for i := 1 to VerticalTabLength do
- writeln(OutFile);
- end {vertical tab};
-
- Procedure ProcessLine(PrintStr: WorkString);
- var TwoRow:boolean;
- var J: integer;
- var TempStr: WorkString;
- begin
- J := length(PrintStr);
- TwoRow := (J >= (PageWidth - RightMargin));
- LineOfSpace[0] := chr(RightMargin);
- LnPrtCount := succ(LnPrtCount);
- CurRow := succ(CurRow);
- if TwoRow then
- begin
- TempStr := copy(PrintStr,1,(PageWidth - RightMargin ));
- delete(PrintStr,1,(PageWidth - RightMargin ));
- CurRow := succ(CurRow);
- LnPrtCount := succ(LnPrtCount);
- end;
- if CurRow > PrintLength Then
- begin
- if banner then
- begin
- Writeln(OutFile,lfcr);
- PrintBanner(PageNum);
- End;
- Write(OutFile,FormFeed);
- PageNum := succ(PageNum);
- VerticalTab;
- if banner then
- begin
- PrintBanner(PageNum);
- Writeln(OutFile);
- end;
- if TwoRow then
- CurRow := 2
- else
- CurRow := 1;
- end;
- if TwoRow then
- Writeln(OutFile,LineOfSpace,TempStr);
- Writeln(OutFile,LineOfSpace,PrintStr);
- end {Process line};
-
- Procedure ProcessFile;
-
- var
- LineBuffer: WorkString;
- FirstWord : WorkString;
- ToRow : Integer;
- label START;
- Function IncludeCheck(VAR CurStr: WorkString): Boolean;
- Var ChkChar: char;
- column: integer;
- begin
- ChkChar := '-';
- column := pos(search1,CurStr);
- if column <> 0 then
- chkchar := CurStr[column+3]
- else
- begin
- column := Pos(search3,CurStr);
- if column <> 0 then
- chkchar := CurStr[column+4]
- else
- begin
- column := Pos(search2,CurStr);
- if column <> 0 then
- chkchar := CurStr[column+3]
- else
- begin
- column := Pos(search4,CurStr);
- if column <> 0 then
- chkchar := CurStr[column+4]
- end;
- end;
- end;
- {Check if include is a string assignment, Trying to be failsafe}
- if ChkChar in ['+','-',''''] then IncludeCheck := False
- Else IncludeCheck := True;
- end { IncludeCheck };
-
-
- Procedure ProcessIncludeFile(VAR IncStr: WorkString);
-
- var NameStart, NameEnd: integer;
- IncludeFile: fvar;
- IncludeFileName: Filename;
-
- Function Parse(IncStr: WorkString): WorkString;
- begin
- NameStart := pos('$I',IncStr)+2;
- while IncStr[NameStart] = ' ' do
- NameStart := Succ(NameStart);
- NameEnd := NameStart;
- while (not (IncStr[NameEnd] in [' ','}','*','''']))
- AND ((NameEnd - NameStart) <= PathLength)
- do NameEnd := Succ(NameEnd);
- {An extra check to see if this is a string assignment}
- if IncStr[NameEnd] = '''' then
- begin
- Parse := MainFileName;
- exit;
- end;
- NameEnd := Pred(NameEnd);
- Parse := copy(IncStr,NameStart,(NameEnd-NameStart+1));
- end {Parse};
-
- begin {Process include file}
- ProcessLine(LineBuffer);
- if not IncludePrint then
- exit;
- IncludeFileName := Parse(IncStr);
- if (pos('.',IncludeFileName) = 0) then
- IncludeFileName := IncludeFileName + IncDefExt;
- {Some documentation has an example to include the documented file}
- {Protect against recursive listings}
- if IncludeFileName = MainFileName then
- exit;
- If not Open(IncludeFile,IncludeFileName) then
- begin
- LineBuffer := 'ERROR -- Include file not found: ' + IncludeFileName;
- ProcessLine(LineBuffer);
- end
- Else
- begin
- MakeBanner(IncBannerStr,IncludeFile,IncludeFileName);
- CurBanner := addr(IncBannerStr);
- if PageFeed and (CurRow <> 4) then {Try to avoid single line pages}
- begin
- if banner then
- begin
- for ToRow := CurRow to PrintLength do
- writeln(OutFile);
- PrintBanner(PageNum);
- end;
- write(OutFile,FormFeed);
- PageNum := succ(PageNum);
- VerticalTab;
- CurRow :=1;
- end
- else begin
- writeln(OutFile);
- CurRow := succ(CurRow);
- end;
- GoToXy(1,5);
- clreol;
- write('Processing : ',IncBannerStr);
- GoToXy(62,1);
- Write('I');
- if Banner then
- PrintBanner(PageNum);
- while not eof(IncludeFile) do
- begin
- if QuickList then
- begin
- ReadLine(IncludeFile,LineBuffer);
- GetFirstWord(LineBuffer,FirstWord);
- If KeyCheck(FirstWord) then
- begin
- ProcessLine(LineBuffer);
- repeat
- ReadLine(IncludeFile,LineBuffer);
- GetFirstWord(LineBuffer,FirstWord);
- If NOT OptWord_Check(FirstWord) then
- if Ord(LineBuffer[0]) > 0 then
- ProcessLine(LineBuffer);
- until OptWord_Check(FirstWord)
- end;
- End Else Begin
- ReadLine(IncludeFile,LineBuffer);
- ProcessLine(LineBuffer);
- End;
- end;
- close(IncludeFile);
- if PageFeed then
- begin
- for ToRow := CurRow to PrintLength do
- writeln(OutFile);
- if banner then
- PrintBanner(PageNum);
- write(OutFile,FormFeed);
- PageNum := succ(PageNum);
- VerticalTab;
- CurBanner := addr(MainBannerStr);
- CurRow := 1;
- if Banner then
- PrintBanner(PageNum);
- end
- else begin
- if banner then
- begin
- CurBanner := addr(MainBannerStr);
- PrintBanner(PageNum);
- End;
- End;
- end;
- GoToXy(1,5);
- clreol;
- Writeln('Processing: ',MainBannerStr);
- GoToXy(62,1);
- Write(' ');
- CurBanner := addr(MainBannerStr); {this is to make sure}
- {I think it is unnecessary}
- end {Process include file};
-
- begin {ProcessFile}
- MakeBanner(MainBannerStr,MainFile,MainFileName);
- CurBanner := addr(MainBannerStr);
- GoToxy(50,1);
- Write('Line: ',LnRdCount);
- if FirstFeed then
- write(OutFile,FormFeed);
- VerticalTab;
- if banner then
- begin
- printbanner(PageNum);
- Writeln(OutFile);
- End;
- GoToXy(1,5);
- Write('Processing: ',MainBannerStr);
- if MainHeader then
- begin
- While Not EOF(MainFile) do
- begin
- ReadLine(MainFile,LineBuffer);
- if IncludeCheck(LineBuffer) then
- ProcessIncludeFile(LineBuffer)
- else
- GetFirstWord(LineBuffer,FirstWord);
- If Not KeyCheck(FirstWord) then
- ProcessLine(LineBuffer)
- else goto START;
- End;
- End;
- While NOT EOF(MainFile) do
- begin
- if QuickList then
- begin {quick option}
- ReadLine(MainFile,LineBuffer);
- if IncludeCheck(LineBuffer) then
- ProcessIncludeFile(LineBuffer)
- else
- GetFirstWord(LineBuffer,FirstWord);
- If KeyCheck(FirstWord) then
- begin
- START:
- ProcessLine(LineBuffer);
- repeat
- ReadLine(MainFile,LineBuffer);
- if IncludeCheck(LineBuffer) then
- ProcessIncludeFile(LineBuffer)
- else
- begin
- GetFirstWord(LineBuffer,FirstWord);
- If NOT OptWord_Check(FirstWord) then
- if Ord(LineBuffer[0]) > 0 then
- ProcessLine(LineBuffer)
- end;
- until OptWord_Check(FirstWord)
- End; {if keyword}
- End Else {if quick option}
- begin
- ReadLine(MainFile,LineBuffer);
- if IncludeCheck(LineBuffer) then
- ProcessIncludeFile(LineBuffer)
- else
- ProcessLine(LineBuffer);
- end; {If QuickList}
- End; {While not EOF}
- close(MainFile);
- for ToRow := CurRow to PrintLength do
- writeln(OutFile);
- if banner then
- PrintBanner(PageNum);
- if EndFeed then
- write(OutFile,FormFeed);
- end; {ProcessFile}
-
-
- BEGIN {ProgList}
- Initial;
- ProcCommLine;
- ProcessFile;
- GoToXy(1,6);
- WriteLn('Lines Read: ',LnRdCount,' Lines Printed: ',LnPrtCount,lfcr);
- Flush(OutFile);
- Close(OutFile);
- VidExit;
- END. {ProgList}