PRJL The Project Lister

From wiki.visual-prolog.com

Revision as of 10:43, 20 October 2010 by Ferenc Nagy (talk | contribs)

[mailto:nagy.frank@citromail.hu Ferenc Nagy Hungary

This program is very old. It lists Turbo and PDC Prolog, Turbo C and Turbo Pascal Projects. Once upon a time the project files containes space separated file names. Once upon a time the handling of windows were very simple. When I wrote this program I had Epson FX 1050 Printer. The escape sequences were suited to its IBM mode.

Nowadays project have much more kinds of files: source codes, dialogs, images, so on. Visual Prolog allows to see the source code of build-in packages. If you intended to write a similar program then you would have ask the user whether he/she wanted to see their code. The colored tokens would be demanded too. Project Lister

Author: Ferenc Nagy

Address: Hölgy utca 48. I. 8., Budapest, Hungary 1102.

Versions:

Turbo Prolog 2.0

PDC Prolog 3.1


The provisions of the program

The program makes a full list from projects consisting of a lot of source files. The list embeds all modules explicitly given in the project file and all modules (directly or indirectly) referenced by them. The references are collected by parsing of the INCLUDE instructions according to the TURBO C, TURBO PASCAL and TURBO PROLOG syntax and by parsing of the USES commands according to the TURBO PASCAL USES syntax, respectively.

A summary is made in addition to the numbered list, too. It contains the type, name, length, beginning page number of each file and the type, name and calling line number of the files referencing them.

A batch file is formed, too, which serves for the copying of every found files. Its a sure tool if we save our project by this procedure we will not forget anything from it.

Usage of the program

  1.
     Read the plain text help file PRJL.HLP of the program.
  2.
     The program may be commanded from the command line by keyword parameters but it is able to run in fully interactive mode.

The form of the command line is

PRJL keyword=value keyword=value...

If there is a question mark in it the PRJL.HLP parameter description is displayed. (Put the question mark after the word PRJL or after a keyword=value pair, do not place it nearby an equal sign!)

If one of the following possible keywords is missing the program waits the answer in interactive mode.

Keyword


Question and remarks:

pd


Directory of PRJ files

sd


Directory of source files

id


PASCAL/C include directory (empty value: same as source directory).

l


Name of listing file[,backside file]. If you give here and in the following answer two file names separated by a comma every second page will be written into the second file.

s


Name of summary file[,backside file] (empty: append summary to listing).

m


Printer mode, its characters may be:



6


6 lines per inch



8


8 lines per inch



y


Epson control characters for IBM mode



n


Do not write control characters.



1


1-column print



2


2-column print



3


3-column print

cd


Directory for the copy.

The found files should be copied there.

pf


Name of the project file

In interactive mode the project file may be chosen from a menu displaying the available *.P?J files.

?


In interactive mode '?' from here invokes help.

x


Extension of source files. Default is PRO.


The format of the listing:

The line numbers stand on the positions 1-6 of each column, the source text is between the positions 9 and 58 continued in the next line if necessary. In case of condensed printing there is room for two columns on a 8 inches wide page and for three columns on a 14 inches wide one.



The structure of the project files:

The starting extension may be changed by the contents of the project file whose structure must match the following pattern:

name.ext+name [.ext+...+name [.ext [+]

that is not only the

name +name +...+name +

formed usual PRJ file structure is allowed.

That's why and for the reason that full list of a project must contain the message files, too, I allowed the *.P?J mask. So the user can distinguish his/her ordinary project files from the files triggering the Project Lister.

If there is no file with the given name and and extension in the source directory the program prompts for a new extension in the lower window.

As the data have been collected the program begins to parse the files given in the project file. These files will be called to "main files" further. The file name and the line number is running in the upper right corner of the upper window. As the program reaches an INCLUDE or USES directive it looks after whether the given file or the 'unitname'.pas file can be accessed. The referenced files are displayed in three windows, see included screen copies.

4. As the parsing has been finished the use can edit the saving procedure name c<project_name>.bat:

- F1 asks for help;

- F2 saves the changes without leaving the editor;

- F5 zooms the editor window in/out;

- F10 saves the changes and the changed procedure will be executed with the parameter given earlier by the CD

keyword;

- Esc saves the changes but prevents the execution of

the procedure.

The CD keyword is not fixed in the batch file but the %1 parameters holds it place so the batch file can be used for reverse copy, too.

The working of the program

The program was written in TURBO PROLOG 2.0.

1. Its running starts with the evaluation of the keyword options:

GOAL ----> OPTIONS ----> DEF_... clauses.

2. The project file is parsed after that:

MAIN_FILES ----> SOURCE_NAME clauses.

The file names are stored in the internal database. The state of the files may be "nay" = existing but not listed yet and "absent" = absent from the source directory.

3. The listing device is opened.

4. The following step is the line by line evaluation of the existing files:

LIST ----> IS_INCLUDE ----> STORE_INCLUDE.

The found referenced are stored in the internal database.

5. The lines are prepared for the listing:

- the tabulators are expanded into spaces : NOTABS;

- (r)LM6Żthe code 0..31 control characters are replaced by carets and letters: NOCCHR;

- the lines are broken into 50 character long segments and collected in the internal database:

LINE_BREAK ----> COLLECT.

6. The lines are counted. If the page is full it will be printed. If the odd and even pages are to be separated the listing device is assigned to the other file after the page break:

LINE_COUNT ----> NEW_PAGE ----> FLIP ----> LEFTLINES.

7. When the end of the source file is encountered its state in the internal database in turned into "yes".

8. If there is file in "nay" state in the internal database that will be evaluated according to the steps 4-7.

9. The lines still collected into the internal database are written and the listing device is closed: LEFTLINES.

10. The summary device is opened: OPEN_SUMMARY.

11. The data of the files are retracted from the internal database and they are written to the summary device: LISTED ----> PARTS_PRINT.

(The page collecting and counting mechanism is similar to that of the main listing.)

12. If there are no more file data in the internal database the page buffer is flushed and the summary is closed.

13. The user can edit the C<project_name>.BAT file and if he/she confirmed the editing with F10 this batch procedure is called: EDITMSG ----> SYSTEM.

14. The program has run.

Limitations

DOS 8.3 file names.


The program parses the source text line by line. So it does not recognize the INCLUDE and USES directives if the keywords and the file names are in separate lines. These lines should contain comments and other instructions neither in the beginning nor embedded among the unit names.

If a such directive is commented out in separated lines like this

(*

USES TRACE_PROCEDURES;

  • )

the program will still look for the referenced module.(r)BBŻ