Reformat Genero source files

To create readable source code with a consistent indentation and layout, reformat your Genero source files (.4gl) with the source code beautifier tool.

The code beautifier tool is provided as part of the fglcomp compilation tool. Genero Studio provides an interface to the compilation tool through the use of menu options and preference settings. To fully understand the code beautifier tool, review the topics in the Source code beautifier section of the Genero Business Development Language User Guide.

Set the code beautifier rules

In the preferences for Code Editor, you can set rules for using the code beautifier tool with Genero Studio.

To access the preference page:
  1. Select Tools > Preferences (or, if you are on a Mac, Genero Studio > Preferences).
  2. Select Code Editor > Behavior & Display.
  3. In the Language field, select Genero BDL.
  4. Click the Code Beautifier tab. Note that the items on the tab are disabled.
  5. Select the Use custom settings check box. The items on the tab are now enabled.
Once enabled, you can:
  • Set the column limit. This sets the source line width limit by providing the value for the --fo-column-limit compiler option.
  • Set the indent width. This sets the number of columns used for indentation by providing the value for the --fo-indent-width compiler option.
  • Set the continuation indent width. This sets the indent width for line continuations by providing the value for the --fo-continuation-indent-width compiler option.
  • Select to indent instruction clauses. This boolean option identifies whether to indent instruction clauses by providing the value for the --fo-label-indent compiler option. A value of 1 indents instruction clauses.
  • Select to pack. This boolean option identifies whether to try and put as much as possible onto the same line by providing the value for the --fo-pack compiler option. A value of 0 uses one line for each item.
  • Indent on save. This boolean option specifies whether to automatically apply the formatter when saving Genero source (.4gl) files.
Note:

The --fo-inplace option is not available in Genero Studio, as the result of the formatter is replaced in the editor if the file is opened, or implicitly in the file on disk when the file is not opened.

Run with a file open in Code Editor

With the file open in the Code Editor, select Edit > Format and Indent. The open document is formatted and indented.

From the File Browser

You can format and indent one or more files from the File Browser (the Files view).
  1. Select one or more files. To select multiple files, hold the CTRL key.
  2. Right-click to open the context menu.
  3. Select Format and indent.

The selected files are formatted and indented. For files currently open in Code Editor, it updates the opened files. For files that are not opened, it updates the files on disk.

From Project Manager

You can format and indent one or more files or for all files within a group.
  1. Select one or more files and/or groups.
  2. Right-click to open the context menu.
  3. Select Refactor 4GL Files > Format and indent.
  4. A warning appears. Answer Yes to format and indent all files.

The selected files are formatted and indented. For files currently open in Code Editor, it updates the opened files. For files that are not opened, it updates the files on disk.