Overview and Key Concepts
The User Commands tool lets you add, delete, and edit custom commands in your model.
Once you have created your command you can call it like any other FlexSim command. It will appear in blue when typing code and it will appear in the Command Summary. You can also hover the mouse over the command and press F1 to display the Command Helper.
User Commands are accessed from the Toolbox.
Each parameter should be one of the following types:
var parameter will accept any of the datatypes. To specify multiple
datatypes but not include all datatypes you can concatenate parameters together using a
In the Parameters field you can have optional parameters by enclosing the additional parameters in square brackets at the end of the list:
(var object, num type [, int flags])
The Return Type can be blank or one of following types:
var type indicates that the return type of the function is a
If your command specifies any of the above data types as parameters that will be passed in to the command, you can access those parameters through the param command:
Where num is the rank from the parameter list. For example, if the parameters was specified as:
(treenode dataNode, num maxNumDataPoints, num incrementValue)
You would access those values in your code by:
treenode dataNode = param(1); double maxNumDataPoints = param(2); int incrementValue = param(3);
When you open the command documentation from the menu Help > Commands, the user commands will be shown in the command documentation in addition to all of the built-in FlexScript commands. The description field shown above will be displayed as html so you can use html markup for formatting, such as <b> and <\b> for bold. Because the description allows for html markup, some standard characters do not work properly, such as <, >, &, and new line characters. To display these types of characters, you can use special markup codes, such as ">" (without the quotes) for a > symbol and <br/> for a line break. If any of the commands' descriptions container invalid html markup, FlexSim may throw an exception when you try to open the Users Manual and your commands will not be properly documented.
User Commands has the following properties:
|Adds a new blank User Command.|
|Removes the selected User Command.|
|Reorders User Commands Up or Down in the list.|
|Adds the User Command or All User Commands to a User Library as either a Draggable Icon or an Auto-Install Component.|
User Commands List
Displays a list of all User Commands. Select a command from the list to edit it.
The name of the User Command. In writing code, this name is the name of the command, ie myUserCommand().
Specifies the parameters that can be passed into the command. Each parameter should be
separated by a comma. To access a parameter in code, use the
Specifies the value the command will return. This can be values like, num, treenode, string, etc.
Specifies the short description of the command. The short description displays in the tooltip when the command is typed or you hover the mouse over the command in a code edit window.
The description displays in the Command Summary.
The example displays in the Command Summary.
Here is where you specify the Flexscript, C++ or DLL code for the command.
Saves all changes to the User Command.
Closes the User Command window without saving changes.