Main About Download Schemes Documentation Resources

Introduction & File Format


Flowgorithm's Source Code Viewer allows flowcharts to be converted to several real-world programming languages. These include: Java, C#, Visual Basic .NET, Smalltalk, and many more. The generated source code is created by using program templates. These are files that contain syntactic information about the target programming language such as keywords, formatting, and operator precedence.

This documentation outlines the format and Flowgorithm program templates. It is also useful to use existing templates to create new ones.

File Extension

Program Templates use the file extension fpgt.  However, the Source Code Viewer can open any extension from the file dialog.

Basic File Format

Program templates are saved in a simple text file using the INI format. The goal was to make them easy to both read and write by using just a simple text editor. Flowgorithm program templates support Unicode, so please feel free to use any of the special characters (not just ASCII).

INI files recognize three basic syntactic elements: comments, section headers, and key/value declarations. From these, it is able to represent a non hierarchical tables. The elements are as follows:

Element What it does Example
Comment Comments do not affect the file, but are useful to make notes for the anyone reading the file. ; Comment
Section Sections denote different logical parts of the file. [Section Name]
Key/Value Keys (which are like variables) are assigned values. Key = Value

The section name and key is used to uniquely identify a value. This is roughly equivalent to the tables and rows found in databases.

[Variable ID]
Convention = camel
Normal = {Name}
Conflict = var_{Name}

Line Format

Each line in the template contains up to three sub-values. These allow the following to specified for each line:

  1. Text format/value
  2. Flags that indicate when the line is valid
  3. Any changes in indentation
Line Format
Text | Flags | Indentation

Lines do not need to specify all three values. If the indentation is left blank, for example, the system will assume 0 - or no change.


Many of the different key/values contain "fields" which are denoted by curly brackets (braces). When a program is generated, text is inserted into these fields based on the current object (i.e. expression, statement, etc...). The contents of the field can be directly taken from the object or, in some cases, generated using other parts of the template.

Field names are not case sensitive. Using a double open curly bracket (brace) is the override sequence.

In the following example, the text key contains two fields: {Variable} and {Expression}.

Example - Assignment Statement
Text = Set {Variable} = {Expression}

Most fields are specific to the section where they are used. However, there are a few useful global fields The are designed to overcome limitations of the program template format.

Global Fields Contents
{space} This contains a single space character. Since the file format automatically trims leading/trailing spaces, this variable can be used to explicitly add it to a program.
{pipe} The pipe | symbol is used to separate the three sections of a line. To allow the pipe to be used in your program, this variable contains a single |.

Multiple Lines

INI files, which Flowgorithm program templates are based upon, generally do not allow a key to contain multiples values (or lines). However, program templates allow any key to contain multiple values (or lines). These can represent different possible values or different lines in a generated statement. To add another value/line to a key, start the next line with an equals sign =.

Example - While Statement
Text = while {condition}
= -->BLOCK
= end while


When source code is generated, the system needs to either include or exclude lines based on information about the program itself. This can be related to whether a specific syntax is needed, different library calls are needed (based on the data type used in an statement), etc....

To control which lines are valid in the program template, the system makes use of flags. The flags are defined by the section in which they are meaningful and can be used to control the generated source code. Multiple flags can be delimited by commas. The line is only considered valid if - and only if - all the flags are matched. If a flag is preceded with a tilde ~ the system will match it if it is False.

The following example makes use of several flags - in particular "inc" and "step". In the context of a For Statement, "Step" is set to true of the For Statement has an step value other than 1 and "inc" is true if the For Statement moves in ascending order (positive).

The combination of these values will result in one line (beginning with for) to be selected.

Example - For Statement
Text = for {Variable} = {Start} To {End} | inc, ~step
= for {Variable} = {Start} To {End} Step {step} | inc, step
= for {Variable} = {Start} To {End} Step -1 | ~inc, ~step
= for {Variable} = {Start} To {End} Step -{step} | ~inc, step
= -->BLOCK | | 1
= end for


Most programming languages allow the use of indentation to visually format the text. This allows blocks and other syntactic elements to be easy to distinguish and understand by the programmer. The last sub-value of a line can contain the change in the generated code's indentation.

In the example below, the line that contains "--->BLOCK" (which has an empty flags) has a single "1" for indentation. This will cause the inserted text to be indented by 1 level.

Note: this does not refer to characters, but the indentation level. The indentation level is automatically converted into a fixed number of spaces in the generated code.

Example - While Statement
Text = while {condition}
= -->BLOCK | | 1
= end while