S T R U C T O R I Z E R - User Guide
Features > Source code generator

Structorizer allows you to convert your designed algorithm to several programming languages (among them Pascal/Delphi, Java, C, C++, C#, BASIC, Python) and even some script and shell languages.

Code export to file

To generate source files, select the respective menu item of submenu "FileExportCode". See Export Code for more details and Export Options for possible generator configuration items.

In most cases, however, you may not expect a flawless and instantly compilable or executable code. This wouldn't be feasible because a (more or less syntax-free) Nassi-Shneiderman diagram will usually not specify all details a specific language might require.

What you yet will obtain is an almost correct algorithmic skeleton that will have to be post-processed a bit manually to achieve a working program or routine. Typically, variable declarations will have to be provided, for instance. Or some algorithmic features like exit Jumps or PARALLEL sections may not be supported by the target language. "TODO" comments placed in the code will help the beginner in perceiving what is to be done to accomplish the output. Despite the incompleteness code export will already help the programming beginner a lot. And even experienced programmers who want to document their algorithms are spared a lot of duplicate work if they start with Structorizer and then just export and adaptate the designed algorithm.

Please be aware that for many languages there are a lot of dialects out there. So it's not unlikely that the derived code may work with one system but cause errors with another. (However, if you think that the exported code serves too exotic a dialect and should better be replaced by a more compatible output, just contact the Structorizer team, please, and raise an issue, ideally giving a reference to the respective programming language specification or documentation. Possibly, some additional export options might be introduced to address diverging demands.)

Live Code Preview (since release 3.30)

From release 3.30 on, you may watch the code that would be exported into your favourite programming language grow while you edit your diagram.

The code preview is enabled via menu "Diagram › Show Code preview?":

The new Diagram menu item "Show code preview"

The Code Preview shares a tabbed pane with the Arranger Index in the right part of the Structorizer main window:

Code Preview (rel. 3.30)

The target language of the code preview is the one configured as "Favorite Code Export" in the Export Options:

Export option dialog with Favorite Code Export

(As outlined in Export Options, it also determines the menu item "File › Export as ...".)

The Code Preview content is updated whenever you modify the diagram, and as soon as you select an element or a range of elements in the diagram then the corresponding code passages (line range) will simultaneously be highlighted and scrolled to as well.

Conversely, when you click on a code line in the preview window then the corrsponding element in the diagram will be selected and the entire code line range derived from it will be highlighted. A double-click in the Code Preview even opens the editor for the associated element.

You may not enter or modify text in the Code Preview directly, however.

The context menu in the Code Preview allows you easily to change the favorite export language without having to open the Export Options dialog (which will be synchronised, of course). In addition, you may launch the code export here conveniently and switch off the Code Preview:

Popup menu in the Code preview

If you keep the Code Preview enabled while you debug your diagram (with Executor) then the orange execution highlighting will simultaneously wander through the Code Preview as well:

Code preview while debugging

(In order to accelerate execution slightly, particularly if done with minimum delay, it is recommendable, however, to hide both Code Preview and Arranger Index during execution.)