How to use the Visual Logic Builder
Visual Logic is very easy to change.
To change a line hold the ALT key and double click it.
To insert new lines of Visual Logic immediately under the currently highlighted line click the RIGHT mouse button or press INSERT. Choose the type of line you want. Once you have chosen a type of line the appropriate line dialog box will appear to help you complete the line.
To insert a new line BEFORE the current line hold down CONTROL when you click the RIGHT mouse button or press INSERT.
In the Visual Logic editor you build up a series of lines that Simul8 reads and obeys at the appropriate time. Each line in a Visual Logic Window is obeyed one-at-a-time. Sub-blocks (for example inside a loop) are obeyed under the control of their parent. For example, if there are 2 indented lines within a loop that is looping from 1 to 5, the indented lines will run 5 times.
Lines can be dragged around to move them. Hold down the ALT key while dragging a line to copy it instead of just moving it (note there is an option in the right-click menu under Edit Options that disables the requirement for ALT if this is preferred).
In addition to copying Visual Logic by holding down the control key while dragging, lines can be copied/pasted to/from the windows clipboard and then into other blocks of Visual Logic (even in other simulations). If you copy some Visual Logic that refers to a simulation object that does not exist in the new context, Simul8 will highlight what objects need to be created in the new simulation.
Code can either be copied using the standard Windows shortcut keys or through the Visual Logic command menu.
As of Simul8 Version 29, Visual Logic comes with three different modes to choose from for writing your code. These are:
You can change Visual Logic mode from the drop-down button while on a Visual Logic section.
Logic Builder is a low-code mode ideal for beginners and those new to coding. When using Logic Builder, you can add code by searching for a command in the left browser and double-clicking on the command you wish to use. This will bring up a window with the relevant command parameters which can be populated by clicking on the three horizontal dots in the parameter fields.
Once you have populated the command’s parameter, click on OK and the code will be added to the Visual Logic section.
Logic Writer, previously known as Free-Edit Mode, is a less restrictive mode than Logic Builder as it allows users to free type in commands and their parameters as needed. When using Logic Writer, each line has to be validated individually. If the current line is not valid (for example, a variable has not been declared), you will not be able to move on to the next line or close down the Visual Logic editor unless you fix the line.
Developer mode is an unrestricted version of Logic Writer. Just like Logic Writer, you can free type in commands and their parameters, with the difference that lines are not individually validated. Instead, any errors in your code will be displayed in the Error List on the bottom of the Visual Logic editor.