home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.barnyard.co.uk
/
2015.02.ftp.barnyard.co.uk.tar
/
ftp.barnyard.co.uk
/
cpm
/
walnut-creek-CDROM
/
CPM
/
TURBOM2
/
SRCLIST.LBR
/
SRCLIST.MOD
< prev
Wrap
Text File
|
2000-06-30
|
4KB
|
123 lines
MODULE sourcelister;
(* translated to Turbo Modula-2 by Glenn Brooke 1/5/87
Ok, another file lister. Yes, it's better. Sigh. Actually, this is
a significant improvement over any other lister I've seen -- it handles
lines longer than 80 characters without screwing up the pagination! It's
especially great for program source listings.
To use, compile with Turbo Modula-2, and run! You can run this as an
.MCD file from within the TM2 compiler/editor shell (it takes about 2K).
The program will prompt you for filenames and whether you want pagination
or not. Pagination provides the filename and page # on each page.
You can modify the source to your heart's content. I use 79 columns per
line and 55 lines per page most frequently.
Important note : program works only with text (ASCII) files.
Intended for the public domain. This program may not be sold
or used for profit without the express written permission of Glenn Brooke.
Glenn Brooke
1025 Garnett Place
Evanston, IL 60201
Lillipute Z-node (312)649-1730
*)
FROM strings IMPORT String, Length;
FROM texts IMPORT TEXT, OpenText, CloseText,EOT,output,CreateText,
ReadLine;
FROM fileexis IMPORT exists;
TYPE filename = String;
VAR
filetolist : filename;
CH : CHAR;
pagination,ok : BOOLEAN;
PROCEDURE ListFile(name : filename; pagination : BOOLEAN);
(*lists files with wraparound, pagination if desired, on lst: device*)
CONST
MaxLinesPerPage = 55; (* you can change these to suit yourself *)
MaxCharPerLine = 79;
VAR
line : String;
i,L, linecount, pagecount : INTEGER;
filetoshow : TEXT;
BEGIN
IF NOT OpenText(filetoshow, Name) THEN
WRITELN("Sorry, couldn't open ", filetoshow);
HALT;
END; (* if then *)
linecount := 0; pagecount := 1;
IF pagination THEN
WRITELN(output);
WRITELN(output,' ',Name,' Page ',pagecount);
WRITELN(output);
ELSE
WRITELN(output);
WRITELN(output);
WRITELN(output);
END; (* if then else *)
WHILE NOT EOT(filetoshow) DO
line := '';
ReadLine(filetoshow,line);
l := Length(line);
IF l <= MaxCharPerLine THEN
INC(linecount);
WRITELN(output,line);
ELSE (*handle lines longer than MaxCharPerLine*)
FOR i := 1 TO l DO
WRITE(output,line[i]); (*WRITE char by char*)
IF i MOD MaxCharPerLine = 0 THEN (*begin new line*)
WRITELN(output);
INC(linecount);
END (*if*)
END; (* for *)
WRITELN(output);
INC(linecount)
END; (* if then else *)
IF linecount >= MaxLinesPerPage THEN (*begin new page*)
WRITELN(output);
WRITELN(output); WRITELN(output); WRITELN(output); WRITELN(output);
linecount := 0;
INC(pagecount);
IF pagination THEN
WRITELN(output);
WRITELN(output,' ',Name,' Page ',pagecount);
ELSE
WRITELN(output); WRITELN(output);
END; (* if then else *)
WRITELN(output);WRITELN(output);WRITELN(output);WRITELN(output);
END; (* if then *)
END; (*while*)
CloseText(filetoshow);
END ListFile;
BEGIN (* main program body *)
WRITELN(" Source file lister -- make sure printer is on!");
WRITE(" Enter name of file to list (RET to quit) : ");
READLN(filetolist);
IF filetolist = "" THEN HALT END;
IF NOT exists(filetolist) THEN
WRITELN(" Sorry, coudn't find ", filetolist);
HALT;
END; (* if then *)
WRITE(" Do you want pagination (Y/N) ? ");
READ(ch);
IF CAP(ch) = "Y" THEN
pagination := TRUE;
ELSE
pagination := FALSE;
END; (* if then *)
CreateText(output, "LST:"); (* send output to printer *)
ListFile(filetolist, pagination);
CloseText(output);
END sourcelister.