Syntax of the code beautifier tool

The source code beautifier option of fglcomp is --format.

Syntax

To beautify a source file, use the --format option of fglcomp:
fglcomp --format [ format-option [...] ]
where format-option is one of:
  1. --fo-inplace: Write formatted output back to the provided file, instead of stdout. Creates a copy of the original file in filename.4gl~
  2. --fo-column-limit=integer: Define the source line width limit. Default is 80.
  3. --fo-indent-width=integer: Number of columns to use for indentation. Default is 4.
  4. --fo-continuation-indent-width=integer: Indent width for line continuations. Default is 4.
  5. --fo-label-indent={0|1}: When 1, indent instruction clauses such as WHEN in a CASE instruction. Default is 1 (enabled).
  6. --fo-pack={0|1}: When 1, try to put as much items on the same line. When 0, use one line for each item. Default is 0 (do not pack).
  7. --fo-lowercase-keywords={0|1}: When 1, produce lowercase keywords. When 0, produce uppercase keywords. Default is 0 (uppercase).
For example:
$ fglcomp --format --fo-column-limit=70 --fo-indent-width=6 mysource.4gl

Configuration file

Formatting options (--fo-*, except --fo-inplace) can be provided in a configuration file named .fgl-format.

The fglcomp tool will search for the .fgl-format file in any of the parent directories of the source passed as argument.
Tip: Place the .fgl-format configuration file in the top directory of your project, to use the same formatting options for all sources located under this directory.

The .fgl-format configuration file is a simple text file with lines defining formatting options. Lines starting with a hash character (#) are ignored.

Note: The --fo-inplace option is not read from the configuration file: This option must be specified as a command line parameter.

Example:

# My code formatting options
--fo-column-limit=80
--fo-indent-width=4
--fo-continuation-indent-width=4
--fo-label-indent=1

Plugging the beautifier into VIM

For vim users, it is possible to define a function key to invoke the source code beautifier, and indent the current source file with a simple key stroke.

Add the following line in your ~/.vimrc resource file:
au BufNewFile,BufRead *.4gl map <F2> mx:1,$!fglcomp --format -<CR>’x

From now on, when editing a .4gl source with VIM, F2 will format the whole source.

For more details about VIM configuration, see Configure VIM for Genero BDL.