S T R U C T O R I Z E R - User Guide
Elements > Jump

The Jump element indicates some kind of exit from a loop, a routine, or a program. It is not actually a means of structured programming, it rather contradicts the ideas of this concept. It can always be avoided (see example below), but may sometimes be a pragmatic and convenient way to formulate algorithms that otherwise would require some complicated workaround with logical variables, additional conditions etc.

You are not encouraged to use Jump elements, however.

The following types of "jumps" are supported both on execution and code export:

  1. Loop exit: an empty Jump element or a Jump element containing simply the keyword
    will just prematurely leave the closest surrounding loop, no matter of what kind. (This form is roughly equivalent to the break statement in languages like C, Java etc.) If the Jump element is contained by several nested loops, then an instruction
    leave n
    (n being a positive integer) within the Jump element will exit from the innermost n loops, such that execution continues with the next instruction after the outer one of the left loops.
  2. Routine exit: To leave a routine (the current diagram) immediately, write
    into the Jump element. This can also be used to return a result value. So if the routine is to provide a result then just write an expression describing the result value or its computation after the keyword return, e.g.
    return a * (b + 3).
  3. Program exit. The keyword
    allows you immediately to terminate the entire program, even from within a subroutine. An added integer value would be used as exit code, e.g.
    exit 17

Note: Beyond version 3.28-12, the keywords mentioned above (leave, return, exit) may be subject to customization, see Parser Preferences.

Example for a conditioned Jump used to leave a For loop prematurely:

Exit from a For loop

Of course the Jump could easily be avoided by decomposing the For loop into a While loop (green and yellow elements) using both the negated condition of the alternative and the maxIterations limit as (re-)entry condition:

Loop avoiding a leaving jump

Instruction transmutation

If you happened to write a jump statement of one of the supported kinds into a simple Instruction element by mistake, then you don't need to delete the element, insert a Jump element and enter the entire statement again. By clicking the magic wand button Magic wand (transmutation button) (with the Instruction element selected) you may transmute it into a Jump element (with same content). This can also serve as an easy test whether the statement complies with the syntax rules stated above. (Otherwise the transmutation button simply won't work.)