Writing code with Logic Writer and Developer mode

Logic Writer, previously known as Free Edit Mode, and Developer are a feature in Simul8 Professional that allow the user to free-type directly into the Visual Logic window, rather than using a right-click wizard. To switch to Logic Writer or Developer mode, open an existing section of Visual Logic (or open a New section and insert at least one line using the Visual Logic wizard). Then choose Logic Writer from the drop-down button in your Visual Logic editor window.

Simul8 Logic Writer

Logic Writer mode features

There is additional functionality in Simul8 Professional that 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.

Simul8 Visual Logic auto predictor

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

Simul8 Visual Logic auto predictor - disable

The predictive functionality provides a list of options based on the characters that are being typed. The command that is closest to the characters that have been typed will be highlighted in yellow. To select the highlighted option hit the TAB key or double-click on the selection. If the command highlighted is not the correct command, continue typing to refine the suggestions or select other items from the list provided by scrolling your mouse or using up and down arrows. Use double-click or TAB to insert your selected item. Hovering the mouse over the command will cause a prompt to be provided to show the parameters that are required to complete the command. The user is required to enter the comma separators for VL commands that require the input of more than 1 parameter. Simul8 automatically populates the brackets and column/row prompts when a spreadsheet item is selected from the list.

Using Logic Writer mode

To complete the editing of a line, press the ENTER key. Simul8 keeps checking the syntax of your code as you type. While the syntax is incorrect, the whole line will be colored red. Once the syntax is correct, Simul8 will change the line color to blue (Note, that various Objects, such as variables and parameters might be colored differently). You will only be able to move to the next line when the current line is syntactically correct. The user must correct the line of visual logic or Delete Current Line using the right-click option before being able to do anything else.

Blank Lines

Blank lines can be put between blocks of code that will not affect the execution of the code during the simulation. This can help in debugging and to also make the code easier to read.

Moving Lines of code

To move a line of code this can be done by clicking the line then holding the left mouse button and dragging. If CTRL is held while doing this, instead of moving the line it will instead copy the selected line to the new location. If you find yourself dragging lines across by mistake, you might want to change your settings to require ALT to be pressed to drag lines. This can be done by right-clicking on the editor and un-ticking “Allow line move dragging without ALT” in the Editor Options. Moreover, there is a range of Visual Logic Editing options, you might want to consider when using the Free Edit mode.

Selecting multiple lines

To select multiple lines of code, click on the first line, then press SHIFT and click on the last line of the block to be copied and this will highlight all the lines in between as well. If you are selecting lines at several different places, use CTRL, instead of SHIFT, as you click on each line you would like to select.

Making changes to a command

To edit a line of Visual Logic once it has been accepted, either use Logic Writer mode to make the changes, or to open the command dialog box double-click on the line with the left mouse button.

Using Developer mode

Developer mode is an unrestricted version of Logic Writer. This allows you to write code quickly and efficiently without the need to validate each line individually. Code can be added as and when needed, and any errors can be rectified at a later stage.

To help you review and correct your code when using Developer mode, an Error List will appear at the bottom of the Visual Logic editor to bring any errors to your attention. You can also double-click on any error in the Error List and you will be taken to that line of code.

Simul8 Developer mode - Error list

Switching Visual Logic mode

To switch Visual Logic mode, use the drop-down button in the Visual Logic ribbon. Please note that any errors should be fixed before being allowed to switch Visual Logic mode.

See Also