Syntax and Tips

Like every programming language, Visual Logic (VL), Simul8’s scripting language has got its set of rules that define the combination of symbols for constructing statements correctly. This help file explains the combinations that the VL syntax comprises of in Simul8. It also presents commonly used shortcuts, tips that will help you compose your Visual Logic blocks more easily and quickly, and some common mistakes users do when starting to use Visual Logic.

These tips only apply to the use of Logic Writer and Developer mode that allows you to free-type directly in the Visual Logic Editor. If you prefer the non-Free Edit mode, the Visual Logic Builder will handle the syntax for you.

Please note, this is not a tutorial for building Visual Logic blocks and their functionality but rather a set of tips to advance your use of VL. Instead, if you are only getting started with VL, have a look at the Beginners’ Tutorial in Visual Logic

Symbols in VL and their syntax

1. Commas ( , ) are used for separating parameters when more than one parameter is required in a command. In the following example, the Set Resources Required command uses 4 parameters and Activity 1 is the first parameter.

Visual logic syntax commas

2. Double quotation marks (“ ”) are used for declaring text variables. The example below sets the lcl_colour Local text variable to the word red.

VL Syntax quotation marks

3. Single quotation marks (‘) are used for writing comments, and once used the characters on the line become green.

VL Syntax comments

4. To check if a variable doesn’t have any value assigned to it, double-quotation marks can be used.

VL Syntax empty

5. Use the plus sign (+) to combine text with a numeric value.

VL Syntax plus

6. Use square brackets ( “[ ]” ) instead of parentheses ( “()” ) for declaring expressions.

7. For conditional statements using IF, the AND conditions are represented with an ampersand ( “&” ) and the OR conditions are represented with a vertical bar (“I”). When constructing such conditions, statements should be bracketed in order to check whether they are equal to 1 as shown below. This is to evaluate whether the condition is met or not.

Simul8 Compound IF Statement Syntax

8. Use three of these signs “ > > >” between each parameter of the Loop command.

Simul8 VL syntax loop

Hints and Tips

1. Use the auto-predictor: This predicts the command, object name, distribution name, variable and label (etc) that is being typed. This can aid your syntax and help you with Object names in large simulations.


To access this functionality, make sure that the ‘free edit mode’ auto predictor under the Editor Options is not disabled.


2. When using the auto-predictor, hit Tab, to use the highlighted option as a parameter.

3. Save time for viewing a spreadsheet’s contents’ by hovering over it on the command line, and press CTRL+F9 to view it while being in the Visual Logic editor.

Simul8 VL CTRLF9

3. When creating a global or local variable, Labels, and Distributions, type the word you want to use as a name, highlight it, right-click on it and select the appropriate option. This saves time from exiting Visual logic and having to go to the Information Store in order to create a variable.

Simul8 VL create variables

4. Instead of multiple IF statements, use ELSE IF statements after the first IF is used. This speeds up the simulation, as it doesn’t need to check whether every IF after the first IF is true.

5. Use break points : When using a break point on a line, immediately before this line of logic is obeyed Simul8 will stop and display the line in the Visual Logic editor. This lets you see when and part of Visual Logic is obeyed, and helps with validation. To use it, click on the circle on the left of the line so it becomes red.

Simul8 VL breakpoints

6. Use the Visual logic command “A Command”: This does not execute any logic, but when combined with break points, it is useful for validation.

7. Use the Display Message VL command: This is useful for checking your logic or displaying special information to user.

8. Visual Logic is not case-sensitive and it deletes unnecessary spaces on each command if included by mistake. When hitting Enter or clicking on another line, Visual logic will automatically apply the correct spacing and case to each line.

9. Use Syntax Highlighting to change the background colour or the colours various variables appear with in Visual Logic. This will make the way the VL editor displays softer for your eyes.

Important Keys and Shortcuts

This section lists the most commonly used shortcut keys in Visual Logic, you can visit the Shortcut keys page for an extended list of all Shortcuts in Visual Logic and Simul8.

Please note that the following shortcuts apply to Free edit mode only, for non-Free edit mode, you can right-click on the line and carry out these actions.

  • CTRL+C or Alt+C: To copy a line
  • CTRL+X or Alt+X: To cut a line
  • CTRL+V or Alt+V: To paste a line
  • CTRL+D: To delete a line
  • CTRL+A: To select all lines in a Visual Logic block
  • CTRL+F: To find
  • If you want to copy, cut, or delete multiple lines at the same time, select the first line, press SHIFT, and while pressing SHIFT select the last line. All highlighted lines will be coloured blue.

Simul8 VL Shift

  • Alt+D: To disable a line
  • Alt+Backspace: To move the line up a branch, used for indentation.
  • BACKSPACE – To delete a blank line

Common mistakes to avoid

1. Make sure to separate Parameters with commas and not with any other punctuation signs like full stops, spaces, or dashes.

2. When checking IF conditions, and you use multiple IFs, there is a risk of the IFs after the first IF condition never being checked. Use ELSE IFs for VL to check every condition in a Visual Logic Block.

3. First, create the Global/Local Data items, Distributions or Labels as discussed previously or through the Information Store before using them as Parameters. If you don’t, the command will remain incomplete (that is represented with a red colour), and you will not be able to move to another line or block.

4. If you are creating a variable using the Create Global Data Item VL command, before using the variable you are creating, make sure to run the Create Global Data Item command. Otherwise, Visual Logic won’t permit you to use a command later on including the variable you are creating using the Create Global Data item command.