S T R U C T O R I Z E R - User Guide
Diagram > Transmute element


The function to transmute (convert) elements or sequences of elements into elements of a different type may facilitate the editing of Nassi-Shneiderman diagrams significantly. This is particularly helpful to make e.g. a subroutine call or an exit operational for the Executor or to merge or split several instructions in order to improve the diagram layout or to allow the setting of breakpoints between instructions that had formed a common Instruction element.

Unstructured (simple) elements (Instructions, CALLs, or EXITs), sequences of simple elements, counting FOR loops, CASE, and IF elements may be transmuted. Simple elements with a single line may change their type. Simple elements with several lines will be split, a sequence of simple elements will be merged. On merging simple elements, the type of element will only be preserved if all elements are of the same type, otherwise the result will be "downgraded" to a multi-line Instruction. A FOR loop or a CASE element will be decomposed (see below).

To initiate a transmutation of the selected element or subsequence you may:

  • press the Transmute symbol (wand) button;
  • activate the respective menu item "Transmute" in either the "Diagram" or the context menu;
  • press the accelerator key combination <Ctrl><T>.

These controls are only enabled if there is a suitable selection (see below).

The following table lists the available conversions depending on the current selection:

Possible transmutations
Selected Lines Prerequisites Result
single Instruction element 1 CALL syntax CALL element (same content)
single Instruction element 1 Jump (EXIT) syntax EXIT element (same content)
single Instruction element ≥ 2   Sequence of single-line Instruction elements (split)
single CALL element 1   Instruction element (same content)
single CALL element ≥ 2   Sequence of single-line CALL elements (split)
single EXIT element 1   Instruction element (same content)
single EXIT element ≥ 2   Sequence of single-line EXIT elements (split)
Sequence of Instruction elements     Multi-line Instruction element (merged)
Sequence of CALL elements     Multi-line CALL element (not excutable!)
Sequence of EXIT elements     Multi-line EXIT element (not executable!)

Mixed sequence of Instruction,
CALL, or EXIT elements

    Multi-line Instruction element
FOR loop   counting style WHILE loop with auxiliary instructions
CASE element     Nested IF elements (possibly with auxiliary assignment)
IF element   non-empty FALSE branch IF element with flipped branches and negated condition

All transmutations are undoable and redoable. For some of the transmutations there is even a reverse transmutation, but not for all.


As shown by the following figures, a single wand button click is sufficient to convert a multi-line instruction element into a sequence of instructions (and vice versa):

Selected multi-line Instructionleft and right wand arrowsSelected sequence of Instructions

Having selected the second element of the splitting result, a subsequent transmutation would convert the instruction into a CALL element because it matches the syntactic requirements of an executable subroutine Call (see also Executor):

Selected single Instructionleft and right wand arrowsSelected single CALL element


The transmutation of a FOR loop (of "counting" flavour) decomposes it into a WHILE loop with separate initialisation instruction and embedded incrementing/decrementing instruction. This operation is particularly sensible if an additional condition is needed to control the loop. And, of course, in order to demonstrate the equivalence of both constructs.

If the decomposed FOR loop was coloured then all substituting elements will inherit the same colour (see images below after separate transmutation of both inner FOR loops).

Note: There is no reverse transmutation for a FOR loop decomposition (it is only undoable during the current session)! And there is no transmutation for traversing FOR loops (aka FOR-IN loops) by now.

Diagram with two FOR loopsTransmutation arrow (irreversible)Diagram with one of two FOR loops decomposed

The transmutation of a CASE structure decomposes it into an equivalent set of nested IF statements. If the discriminator is not a variable but some kind of expression to be computed then an instruction element assigning its value to a generically named variable is inserted before the outer replacing IF statement. This way, repeated computation of the discriminating value is avoided, which does not only preserve performance but also consistence. Such a decomposition may be sensible if you have to compare with non-constant values (as are required by a CASE structure) or against intervals. (Besides, the transmutation demonstrates the equivalence of the constructs and the elegance of a CASE structure in comparison.)

If the decomposed CASE element was coloured then all substituting elements will inherit the same colour (see images below — before and after transmutation of a CASE element):

Diagram with a CASE structure
Transmutation arrow downwards (irreversible)
Diagram with a decomposed CASE structure

Again, there is no reverse transmutation, i.e. you may not compose nested or chained IF elements to a CASE element automatically.

An IF statement (alternative) with awkwardly formulated condition (e.g. such that you would have to leave the TRUE branch empty — which isn't allowed) may easily be flipped, provided that the ELSE branch hadn't been empty (which would result in an illegal IF element with empty TRUE branch):

Selected alternativeleft and right wand arrowsFlipped alternative

With the current version of Structorizer, the negation of the condition is not very intelligent (as to be seen in the example above, where n≥2 would have been a more sophisticated result), but at least a repeated flip won't inflate the expression with more and more encapsulating not operators. (A later version may perhaps improve the logical inversion.)

Handling of comments on merging, splitting, and decomposing

On merging instructions the transmutation mechanism tries to concatenate the comments of the combined elements in such a way that the resulting multi-line comment can be split and correctly re-assigned to the original instruction elements again. But note that this effort may be spoiled in the following cases:

  • The resulting multi-line element is manually edited;
  • The resulting multi-line element is merged with further instructions.

If an unambiguous re-distribution of the comment lines is impossible on splitting then the first of the separated instructions will obtain the entire comment while the following elements will end up with an emptied comment.

The comment of a decomposed FOR loop is transferred to the replacing WHILE loop. The two created auxiliary Instruction elements will not inherit comments.

The comment of a decomposed CASE element will be inherited by the first of the replacing elements, i.e. either by the discriminator assignment (if inserted) or by the outermost IF statement.