The formatter can standardise all aspects of Delphi Object Pascal source code formatting, including indentation, spacing and capitalisation. If you are still not sure, see the examples of program input and output . It works on Delphi and Delphi.NET syntax.
It is useful if you are taking over code and don't like the original formatting. It is useful if you are trying to bring code from multiple sources to one standard.
A human can always produce better formatting than a program, but in many cases they don't. If you find a piece of code's formatting annoying or hard to read, this program can save you a lot of time.
On your own code it can catch your mistakes, and even automate some mundane tasks that may have annoyed you but you haven't bothered with up to now (e.g. to turn tabs to spaces, standardise indentation, spacing and capitalisation, globally change a variable or procedure name, globally remove redundant unit from all uses clauses, or even to insert the MPL licence comment into all units).
You should format your Delphi programs as per this program's default settings, i.e. as Borland suggests.
This program is free and open-source.
As of version 2.37, JCF is avaialble under a dual licence - Mozilla Public Licence (MPL) 1.1, or GPL 2.0 or later.
The original licence was the MPL - I chose the MPL particular open-source license at the suggestion of the Delphi-JEDI group. the GPL was added at the request of members of the Lararus project, who use this licence, and would like to link in JCF code.
If you improve this program in any way (bug fix, new feature, better algorithm, whatever), I would appreciate it if you send those improvements back to me for possible inclusion in a future version.
Disclaimer: This program may have bugs or not yet fully meet it's design objectives. Although it has been fairly well tested and is used with some success, I cannot make any guarantees. If you care about the quality of this program, send in bug reports.
I recommend using a source control system such as Subversion, Microsoft TFS, CVS, TeamSource or the like. Remember "Source control is like flossing - you don't have to floss all your teeth - just the ones you want to keep." If you are still not using such a tool, please make backups before using the formatter.
This version is downloadable as source or as executable.
Install the executables as follows:
JCF2Settings.cfgin your windows directory.
JcfNotepad.exeto experiment with files.
JcfGui.exeto format files from the gui - this is good when you have a directory or directory tree of Delphi files that you want to format.
jcf.exeif you are making a batch file or you are masochistic.
The Delphi IDE pluggin can be installed for Delphi 7 as follows. All
packages can be installed by selecting the menu
Component|Install packages and clicking the "Add"
Install the source as follows:
Things that can go wrong with compilation:
View|Project managerand open the first project, JediCodeFormat.dpr instead.
[Fatal Error] JediCodeFormat.dpr(142): File not found: 'JclStrings.dcu'."The JCF files and JediComponents files are not included in this zip file. You may have placed them in a different location on your hard drive. Change the paths in the
JediCodeFormat.dpr, Jcf.dpr and Jcfide.dpkfiles.
Outputdirectory is not found. I like to configure Delphi to write the
.dcufiles and executables to an output directory. Naturally, when distributing the source, this directory is empty. WinZip doesn't store empty directories, so it may not exist after you unzip. Sometimes I remember to put a dummy file called Delme.tmp in this directory. If you see that file, it has already served it's purpose and may be removed. Make an
Outputdirectory under your CodeFormat directory, or clear (or change) this setting in Delphi's
Jdfide.dpkgives a lot of warnings about implicly imported units. Yes it does. It's not serious.
Report the bug here. Submit a test case and (optionally) a fix to the source, and tell me which if these categories, ordered by severity, that you think the bug falls into:
Breath. Calm down. Remember that I am offering this program free and without any guarantees. Remember that I did not force you to use it. Remember that I strongly suggested that you make backups. Constructive suggestions, especially those with code, will be kindly treated. Flames will be deleted. I haven't had any flames yet for this program, and I'd like to keep it that way.
This program is mostly in maintenance mode now - I fix bugs, track changes in Delphi versions and language syntax, and release an update every month or two.
The goal for Version 2.0 is that the program should have no bugs and generate output compliant with official code formatting standards (and have options for other styles). It should allow the user to configure anything that needs to be configured, and it should not overload the user with useless options.
It should also have, in order of priority: readable source, an easily extendable and well-documented architecture, and should run fast enough.
You could look for Delphi code tools at The
inner circle project.
You could look for the API translations, code library and components at The Joint Endeavour of Delphi Innovators (project JEDI).
GExperts is Open source programming tools for Delphi and C++ builder. Not only are they good tools, the source is good examples on how to do this kind of thing.
There are several sites that act as clearing-houses for Delphi shareware, components and free code.
Yes, it is designed with only Delphi in mind. However it may work on other dialects of Pascal. I have no way to test this as I only use Delphi, but if you have any luck, let me know. If you would like JCF to support a syntax element from another dialect of Pascal, then send me a code sample please!
For other languages such as C, Java and so on - do a search on the web and you will probably find a selection of tools.
me via the forums