SIMUL8 logo

Object Speed Code Lists

Object Speed Code Lists are a way of quickly set Object Variables. It is particularly important when using Components or in any simulation where a large number of Objects are being referenced in Visual Logic in a dynamic manner.

For example:

When an Object is referenced by an Object variable using a command similar to:

 Set MyObjectVariable = "Activity 1"

then SIMUL8 internally searches for the string of text “Activity 1” and when a match is found the object variable is linked to the actual object.

However, when the number of such commands gets large, as could be the case when building a simulation from Components, or looping through a long spreadsheet of names, then a decrease in execution speed can be detected because each text search can take a long time in a simulation that contains many names. Object Variables themselves are very fast, but setting them to new values, without speed lists, can be slow.

A Speed List solves this by setting up, once at a key moment, a list of internal reference codes that can be used to set Object Variables without text searches.

A Speed list is just a SIMUL8 Spreadsheet with 2 columns, one containing text names of the relevant simulation objects and the next containing the internal reference codes (these are automatically generated).

Set up a Speed Code List from the Developer tab. Add a sheet and specify the top of a column that contains names of objects you want to use in Object Variables.

Then, in your Visual Logic, instead of a normal SET command, instead use the following command to set relevant object variables:

  Set Object Var from Object Speed Code MY_Sheet_of_Objects[1,row] , MyObjectVariable

where “row” in the above is the number of the row containing the text name of the relevant object.

The reference codes (in the second column) are automatically updated: Each time the simulation file is opened, and if SIMUL8 detects a need to update it while the file is open (for example if you change, through VL or otherwise, the text in the first column). If you set up a Speed List and then use “Set Object Var from Object Speed Code” before the reference codes have been generated then they will be automatically generated before “Set Object Var from Object Speed Code” returns.

Other Visual Logic commands

Object Speed Code Lists can be dynamically created from Visual Logic, if required, using Add Speed List Location

For example:

To add a Speed List location:

  Add speed list location ss_Objects[1,1]

Using a Speed list spreadsheet for multiple purposes

The same spreadsheet can be used for multiple speed lists (for example one list might be in columns 1 and 2, another in 3 and 4. You can also use other columns for any other purpose however it is recommended NOT to change the content of any columns (even ones outside the speed list columns) from Visual Logic during simulation runs as such changes will be detected by SIMUL8 as reasons to update the internal reference codes (and this update will slow down the simulation).