Understanding the code beautifier tool

This is an introduction to the source code beautifier tool.

The code beautifier tool built in the fglcomp compiler can be used to reformat .4gl source modules and get a readable source code, using consistent indentation and source layout rules across modules.

Note: The code beautifier supports uppercase or lowercase keyword coding conventions. See the --fo-lowercase-keywords option usage for more details.

Formatting options can be specified on the fglcomp command line, or in a configuration file (it is recommended to use the configuration file instead of commande line options).

The beautifier tool:
  • Indents source lines for nested code blocks
  • Converts language keywords to uppercase or lowercase
  • Adds or removes space characters between tokens
  • Breaks long lines
  • Can use space or tab as indentiation characters
  • Can indent parts of the source file

By default, the new reformatted source code is written to the standard output stream (stdout). Use the --fo-inplace option to replace directly the original source file.

Important: The input source file must compile. Indenting a source file with errors will produce an unpredictable result.
In addition to the fglcomp --format tool, other command line tools are provided to integrate with version control systems such as GIT and SVN:
  • fglformatdiff can reformat code line changes referenced by a diff command output.
  • fglgitformat can reformat code line changes referenced by a GIT commit. Use this tool instead of fglformatdiff, if GIT is your version control system.