Pascal Source code formatter



This is a simple Pascal source formatter, only meant to give correct and readable indentation to Pascal code.
The tool is started up from within the mP IDE, one of the IDE "tools" is programmed to start up the formatter and pass the currently selected file to it (which has to be "saved" beforehand).
The tool also provides the possibility to open other Pascal files via the "File" menu.

The software: PascalFormat.zip

Usage

On startup, the pascal source is loaded automatically and the tool shows this window:

new

The left side pane shows the original (unprocessed) source code, and hitting the "Process" button produces the formatted (processed) code in the right hand pane.
This processed source code can be saved (overwriting the original code) by pressing "Save".
Additionally one can, before hitting "Process" trim (delete spaces) the code in the left pane. This is done with a popup menu (right mouse click inside the left pane). Two options are offered: trimming all lines, and trimming only the lines that do not start with a comment.
If wanted, one can reload a saved file in the left page by hitting "Reload"

Remarks:

How to make it work from within the IDE

To make the tool work from within the mP IDE the following has to be done:

1. The tool must be added in the "Tools" (Tools menu --> Options --> Tools --> Toolx) menu:
new

As you can see, the path to the tool must be given and one parameter: "%UNIT_FILE_NAME".


2. Additionally mP has to be told to accept changes in source files made by an external tool, this is done in the IDE menu "Tools -> Options -> Editor -> Editor settings":
new

Details

The tool expects the following to be true in the original source code (précondition): The indentation in the processed file is done according the detection of the following keywords: Additionally,
-------------------------------------------