Visual Logic to Flow Diagram

This feature converts your Visual Logic code to a flow diagram at the click of a button. As well as looking good, being able to visualize your code as a diagram offers many benefits:

  • Enhances understanding of the code structure.
  • Aids the documentation process.
  • Improves code structure.
  • Makes it easier to explain your code to non-technical users.
  • Helps identify structural problems, and thus eliminate them.


To access this feature open the Visual Logic code you wish to convert. In the Visual Logic window you will notice a flow diagram icon (Image 1. 1.). Clicking this icon will convert your code into a diagram, clicking the icon again will bring you back to the code view. When viewing a diagram extra buttons will be available to you allowing you to print (Image 1. 2), export (Image 1.3) and zoom (Image 1.4).

Visual Logic Flow Buttons
Image 1 – Visual Logic Flow Buttons


Image 2 below shows a simple flow diagram. This diagram was generated from the following Visual Logic code:

WHILE Var1  <  10
  IF Var1  =  1
    'This is a test comment
    SET 1  =  1
    SET 2  =  2
    SET 3  =  3
    SET 4  =  4
    SET 5  =  5
  ELSE
    IF Var1  =  1
      SET 5  =  5
  CALL another code block

Visual Logic Flow Diagram
Image 2 – A Visual Logic Flow Diagram


Block Types


In Image 2 you will notice various different images, each represents a different block of the code. Excluding the start and the end block there are 4 key block types:

Code (binary image) Code within this section, i.e. SET var1 = 1.
While (loop image) Code within this section will be run the number of times the loop runs.
If (if image) This represents a decision, if the condition is met (true) the code flow will run to the left, other. Nested if statements appear as a series of If images linking into each other.
Call block (call / telephone image) This represents a call to another section of Visual Logic code.


Hovering over code blocks reveals the code and comments inside, illustrated in Image 3 below.

Block Hover Tips
Image 3 – Block Hover Tips


Visual Logic Flow Diagram Options


Certain behavior of this feature can be modified by right clicking the Visual Logic flow form.

Visual Logic Flow Options
Image 4 – Visual Logic Flow Diagram Options

Display invalid code blocks (F3): Allows you to choose if you wish to display disabled code blocks in your diagram. Lines / blocks of code can be disabled in the code view by write clicking the section then choosing the ‘Disable current line’ option.
Display disabled code blocks (F4): Invalid code blocks represent code that is incorrect, for example an ELSE IF statement with no parent IF is not a valid block. The text ‘(else not valid here)’ will be displayed after the ELSE text in this case. Invalid code blocks are represented in the diagram as an exclamation mark image.
View Code on FlowChart (F5): Displays the decisions statements of your code on the flow diagram, for example if the code for a WHILE block was say: ‘WHILE var1 = 5’ then this text would appear by to the right of that LOOP image. This helps illustrate the impact each statement has in terms of what code is executed. This text replaces the True / False text that is shown by default.


Zooming and scrolling shortcuts.


These shortcuts allow you to quickly navigate / resize the diagram to view the area you are interested in. This behavior is the same as the main simulation window.

Scroll Wheel Zoom in / out
Ctrl + Scroll Wheel Scroll up / down
Shift + Scroll Wheel Scroll left / right
Ctrl + Shift + Scroll Wheel Scroll diagonal (left / right / up / down)


Please Note: This is a Simul8 2009 Professional feature