Commands by Category

AGV

Description
Deprecated, use AGV class.
Gets various information about an agv, based on the what parameter:
AGV_CURRENT_CP - Returns the agv's current control point
AGV_ORIGIN_CP - Returns the agv's origin control point
AGV_INTERMEDIATE_DEST_CP - Returns the agv's intermediate destination control point
AGV_DEST_CP - Same as AGV_INTERMEDIATE_DEST_CP
AGV_FINAL_DEST_CP - Returns the agv's final destination control point
AGV_DEST - Returns the agv's destination object
AGV_BATTERY_LEVEL - Returns the agv's current battery level as a percentage of battery capacity (0 - 100)
AGV_AMP_HOURS - Returns the agv's current battery level in amp hours
AGV_START_RECHARGE - Starts the agv recharging. Returns the time it will take to recharge to full capacity.
AGV_RECHARGE_TO_LEVEL - Explicitly set's the agv's battery level to p1 (0 - 100).
AGV_ADD_ALLOC_POINT - Should be called from the travel initialization trigger. Manually adds a control point/control area for allocation, i.e. a control point or control area that would not otherwise need to be allocated as part of the agv's current travel path. The control point/control area is passed as p1, and the distance at which it must be allocated is passed as p2. The command will return a reference to a node that represents that allocation. Use AGV_SET_ALLOC_POINT_DEALLOC_DIST and AGV_SET_CAN_STOP_AT_ALLOC_POINT to specify further data on that allocation point.
AGV_SET_ALLOC_POINT_DEALLOC_DIST - For a manual allocation point that's been added, this sets the travel distance at which the agv can deallocate the object. You should call this at some point after adding the allocation, so that the object will be properly deallocated. p1 is a reference to the allocation point node returned by AGV_ADD_ALLOC_POINT, and p2 is the deallocation distance.
AGV_SET_CAN_STOP_AT_ALLOC_POINT - Sets whether or not the agv can stop at a manually added allocation point. The default is no, i.e. the agv will not stop at the stop distance, but will continue to the next stoppable point before attempting to allocate the object. Setting this to 1 will allow the agv to stop at the manual allocation point to allocate ahead. p1 is a reference to the allocation point node returned by AGV_ADD_ALLOC_POINT, and p2 is 1 or 0.
AGV_ATTACH_TRAILER - Manually attaches a trailer to the AGV. p1: the object to attach. p2: the trailer gap to apply. p3: If 1, the trailer will be attached behind the AGV (attach to the AGV's tail), if 0, the trailer be attached ahead of the AGV (attach to the AGV's head). p4: If 1, the trailer will automatically be detached when the object exits the AGV, if 0, the trailer should be manually detached.
AGV_DETACH_TRAILER - Manually detaches a trailer from the AGV. p1: the object that is attached as a trailer.
AGV_SPEED - Returns the agv's current speed
AGV_PROXIMITY_STATE - Returns 1 if the agv is blocked by proximity on an accumulating path, 0 otherwise.
AGV_ACCUM_AHEAD_AGV - Returns the agv ahead of this agv on an accumulating path, if one exists.
Example
agvinfo(agv, AGV_DEST_CP);
Description
Returns a control point connection. Also, if connection is a string and controlpoint and rank are both 0, then this command will return the index of the given connection. This is for speed, so that you can subsequently use a number for the connection.
Example
cpconnection(cp, "ForwardTo", 1) Returns the first ForwardTo connection on cp
cpconnection(cp, "LookForWork>NextLookForWork", 1) Traverses two connections to find an object. This is the same as cpconnection(cpconnection(cp, "LookForWork", 1), "NextLookForWork", 1)
cpconnection(cp, "LookForWork:2>NextLookForWork", 1) Same as cpconnection(cpconnection(cp, "LookForWork", 2), "NextLookForWork", 1)
int connIndex = cpconnection(0, "LookForWork", 0);
treenode obj = cpconnection(cp, connRank, 1);
Gets the index of the connection, and then uses the index instead of the name.

Communication

Commands for communicating with external applications such as sockets, database communication, and links with Microsoft Excel.
Receives data sent to the socket
Description
This command receives data that has been sent to the socket specified as socket. The value of socket is the number that is returned by clientcreate(). This command operates differently in flexscript vs. c++. In c++, buffer must be a valid pointer to a char* destination into which the read bytes will be copied. The return value will be the total number of bytes received. Up to bufsize bytes from the clients message will be read and stored in the preallocated character array called buf. In flexscript, however, buffer should be passed as NULL, and the return value will be the actual string that is received. If noblocking = 1, then this command does not block FlexSim program execution, but if noblocking = 0, FlexSim program execution will block (freeze) until something is received from the client.
Example
c++: int bytes = clientreceive(1,Buf,15,0);
flexscript: string readstr = clientreceive(1, NULL, 15, 0);
Opens an ODBC database
Description
This command attempts to open an ODBC database. Returns a 1 for success, 0 otherwise. The database must have an ODBC alias (or Data Source Name DSN) defined before it is opened. This is done using the "Data Sources" option in the Windows Control Panel. The alias name is passed to the command as databasename, the database file name should not be passed. Databases can be opened in two different modes. These modes have slightly different behavior and available commands. The two modes are SQL mode and Table mode. If the parameter tablemode is 1, then the database will be opened in Table mode, and command should be the name of the table in the database to open. If the table is opened successfully, the entire table will be available to read. Individual cells can be edited in Table mode. No SQL commands should be called if the database is in Table mode. If tablemode is 0, then the database will be open in SQL mode and command should be the initial SQL query. If the query executes successfully, only the result of the query will available to read. Individual cells cannot be edited in SQL mode. However, SQL update queries can be called once the database is open. If showlogin is 1 then the standard login prompt (username/password) will be shown before the connection to the database is made.
Example
dbopen("itemdrive","timetable",1);

This opens a database with the alias "itemdrive" and opens the table called "timetable" in Table mode.

dbopen("warehouse","select * from inventory",0);

This opens a database with the alias "warehouse" and performs a SQL query on it. The database is open in SQL mode.
Perform an SQL query on the open ODBC database
Description
This command performs the SQL query specified by query on the currently open database. The result becomes the current table. If the database is in Table mode, this command does nothing. If the query returns a table, that table can be read using the dbgettablecell() command. If the query performed an update, the dbgettablecell() command will cause an exception to occur.
After performing UPDATE statements with this command, a SELECT should be called immediately following, as there is no table returned by an UPDATE. This command is only usable in SQL mode. If forwardOnlyCursor is 1, then it will assume the result is a forward-only-cursor result. For forward-only cursors you cannot use dbgetnumrows(). Instead, after the call to dbsqlquery(), you call dbnextrow(). This command will return the activated row. It will return -1 once it hits the end of the table.
Example
dbsqlquery("select processtime from timetable where type='1'");

This returns a new table based on the SQL query passed.

dbsqlquery("update timetable set processtime=type*2");

This updates the database based on the query passed.
Sets the username and password used to access an ODBC database with dbopen()
Description
This command sets the username and password that will be used to access a database when dbopen() is called next. This allows a model builder to use the login parameters required by a database, without having to use the username/password prompt that dbopen() provides. The username and password set by this command will be used every time dbopen() is called until they are changed by calling dbusername() again. It is acceptable to set either the username, password or both to an empty string.
Example
dbusername("user1","abc123XYZ");

This sets the username to "user1" and the password to "abc123XYZ". These values will be used to access a database the next time dbopen() is called.

dbusername("","");

This clears out the last set username and password. The next time dbopen() is called, the database will be accessed without a username or password.
Launch Microsoft Excel
Description
This command opens Microsoft Excel so that it can be accessed by FlexSim. If launchdir is not specified, the path defined in Tools|Excel...|Global Settings will be used. Otherwise, the launchdir must be an accurate path to the location on the hard drive where EXCEL.EXE is located. It is typically something like "C:/Program Files/Microsoft Office/Office10," but may be different depending on the version of Excel installed. It is generally not required to launch Excel before communicating with it. However, if FlexSim is set to communicate with Excel via DDE (by calling maintenance(1000,1), this is not the default behavior) Excel must be running before any communication can be performed. If excellaunch() is called at the beginning of communication, excelquit() must also be called before the user opens a new model, compiles the current model or closes FlexSim.
Example
excellaunch(" C:/Program Files/Microsoft Office/Office10");
excelopen("C:/mybook.xls");
excelsetsheet("Sheet1");
double thenum = excelreadnum(1,1);
excelclose(true);
excelquit();

This starts Excel, opens a workbook called "mybook," stores a value read from row 1, column 1 from that workbook, then closes the file and Excel.
Gets the server will attempt to accept a client connection
Description
The server will attempt to accept a client connection. If noblocking = 0, the command blocks until a connection is made. It returns an index used to reference the connection made.

The server will attempt to accept a connection from a waiting client. A number will be returned that is the index of the connection established. A return value of 0 indicates that no connection was created. This value will be used in all future server calls. If noblocking = 1, the server will not block FlexSim program execution, but will return a 0 if no client attempts to connect. If noblocking = 0, the server will block (freeze) FlexSim program execution until a client attempts to connect. Connections with clients are only made with this command.
Example
int client = serveraccept(0);
Receives a message from the connection
Description
Receives a message from the specified connection. This command operates differently in flexscript vs. c++. In c++, buffer must be a valid pointer to a char* destination into which the read bytes will be copied. The return value will be the total number of bytes received. Up to bufsize bytes from the clients message will be read and stored in the preallocated character array called buf. In flexscript, however, buffer should be passed as NULL, and the return value will be the actual string that is received. If noblocking = 1, then this command does not block FlexSim program execution, but if noblocking = 0, FlexSim program execution will block (freeze) until something is received from the client.
Example
c++: int bytes = serverreceive(1,Buf,15,0);
flexscript: string readstr = serverreceive(1, NULL, 15, 0);

Conversions

Commands for converting units, data types, and spatial coordinate.
Converts the given value (a time) from one time format to another
Description
Converts the given value (a time) from one format to another. The from and to arguments only accept the following values:

FS_DATETIME
XL_DATETIME
MODEL_TIME
DATE_STR
TIME_STR
DATETIME_STR

FS_DATETIME - the number of seconds since Jan 1, 1601. getmodelunit(START_TIME) returns a value in FS_DATETIME units.

XL_DATETIME - the serialized day number, where day 1 is Jan 1, 1900. Feb 10, 2025 1:30 PM is 45698.5625 in XL_DATETIME units. This format is used in Microsoft Excel for dates.

MODEL_TIME - the number of model units since the model start time

DATE_STR - a string representing the date portion of a datetime value. The resulting text will depend on the date format specified in the model settings. If converting from this format, the value must be formatted according to those settings.

TIME_STR - a string representing the time portion of a datetime value. The resulting text will depend on the time format specified in the model settings. If converting from this format, the value must be formatted according to those settings.

DATETIME_STR - a string representing the time and date of a datetime value. The resulting text will depend on the time and date formats specified in the model settings. If converting from this format, the value must be formatted according to those settings; the time portion must be first, separated from the date portion by a single space.

Note that year 3000 and beyond are not supported by this command.
Example
convert(42308, XL_DATETIME, MODEL_TIME) // converts an Excel date to a valid model time

Conveyor


Deprecated

Commands that are no longer supported, or for which alternative commands have been made. The documentation for these commands has been discontinued, and therefore may be incorrect. Many of the commands still work for backwards compatibility purposes, but we encourage you to use their alternatives instead.
Deprecated, use Math.atan2()
Description
This command is deprecated. Use Math.atan2() instead.

Returns the angle in degrees, rotated clockwise from the positive x axis, of the vector (dx, dy). Calling angle(dx, dy) is the same as calling -Math.degrees(Math.atan2(dy, dx)).
Example
double myangle = angle(distx, disty)
Deprecated, use Object.attrs.assert()
Description
This command is deprecated. Use Object.attrs.assert().

Gets a reference to attribute attributename of object, creates the attribute if it does not exist.
Example
Deprecated, use treenode.labels.assert()
Description
This command is deprecated. Use treenode.labels.assert() instead.

Gets a reference to label labelname, creating the label if it does not exist.
Example
Deprecated, legacy conveyors are no longer supported
Description
Deprecated, Legacy conveyors are no longer supported.

This command is used in conjunction with the BasicConveyor object.

The bcgetitemkinematics command is used to obtain a reference to one of the three kinematics associated with a flowitem traveling on a BasicConveyor:

0 = The main convey state kinematics. You may get kinematic information from this, but do not change the kinematic by adding kinematics or initializing it.

1 = A user-definable kinematics that is dependent on simulation time.

2 = A user-definable kinematics that is dependent on the convey position of the flowitem on the conveyor.

The two user-definable kinematics are available for the user to set up customized kinematic motion in addition to traveling down the length of the conveyor. Use bcgetitemkinematics to get a reference to the desired kinematics node, and then use standard initkinematics() and addkinematic() commands as normal. You will need to use the alternative initkinematics parameter list: initkinematics(node, x, y, z, rx, ry, rz, managerots, localcoords). Also, if you add kinematics to the type 2 convey depend kinematic node, bear in mind that all time units for that kinematic no longer apply to actual simulation time units. Instead, they are interpretted as "convey units". For example, a speed of 5 is no longer 5 units per time unit, but is instead 5 units per conveyed unit. Acceleration is not distance per time squared, but distance per conveyed unit squared. Start times are no longer a time to start the kinematic, but a position along the conveyor to start the kinematic at. As an example, let's say you add a kinematic to the convey dependent kinematic node to travel 1 unit in the y direction with "start time" 5 and "max speed" 0.5. What that translates to for the convey dependent kinematic is that the item will start traveling in the y direction once it reaches 5 units along the conveyor. Also, for every unit that it travels down the length of the conveyor, it will travel 0.5 units in the y direction (0.5 y units per convey unit). Thus it will finish the y kinematic once it has travelled 7 units down the conveyor. If the item is blocked in the middle because of accumulation, say at convey position 6, then its y kinematic will also stop, and not resume until the item resumes along the conveyor.

See bcsetitemconveystate command documentation for a general description of the BasicConveyor object.
Example
treenode kin = bcgetitemkinematics(current, item, 2);
treenode kin2 = bcgetitemkinematics(current, item, 1);

initkinematics(kin, 0,0,0, 0,0,0, 0,0);
addkinematic(kin, 0,1,1,0.5,1,1,0,0, 5, KINEMATIC_TRAVEL);
initkinematics(kin2, 0,0,0, 0,0,0, 0,0);
addkinematic(kin2, 0,0,720,360,0,0,0,0, time()+5.0, KINEMATIC_ROTATE);
Deprecated, legacy conveyors are no longer supported
Description
Deprecated, Legacy conveyors are no longer supported.

This command is used in conjunction with the BasicConveyor object.

The bcsetdirection command stops all flowitems on the conveyor and sets the direction of travel to 1=forward and 0=reverse. All flowitems will need to have their convey state reset with the bcsetitemconveystate() command before they will begin moving again. The example below shows how to stop the conveyor, and then have all the flowitems accelerate up to a speed of 1 in the reverse direction. Any additional item kinematics will still be active after a direction change.

See bcsetitemconveystate command documentation for a general description of the BasicConveyor object.
Example
bcsetdirection(so(),0);
for(int i = 1; i <= so().subnodes.length; i++)
{
     treenode item = so().subnodes[i];
     bcsetitemconveystate(so(), item, bcgetitemposition(so(), item), 0, 1, 0.2);
}
Deprecated, legacy conveyors are no longer supported
Description
Deprecated, Legacy conveyors are no longer supported.

This command is used in conjunction with the BasicConveyor object.

The BasicConveyor object allows flowitems to be moved in and out of the conveyor at any time and at any location. Each flowitem on the BasicConveyor can be assigned and re-assigned its own kinematic profile defining how the flowitem is to move along the conveyor. When one flowitem overtakes another flowitem on the conveyor which is either stopped or traveling at a slower speed, it will slow down immediately to match that flowitem's speed. Although flowitems may travel in either direction along the conveyor, all flowitems will travel in the same direction at any given time. The travel direction of the conveyor is set with the bcsetdirection() command. As flowitems are moved in and out of the conveyor, other flowitems on the conveyor are aware of the increase or decrease in available space along the conveyor, and will accumulate naturally. After a flowitem enters the conveyor, either indirectly with the receiveitem() command or directly with the moveobject() command; it is necessary to define the flowitem's initial kinematic profile. This profile is refered to as the flowitem's "convey state", and it is set with the bcsetitemconveystate() command. The convey state for a flowitem can be set multiple times if desired. The following are definitions for the parameters used to define the convey state of a flowitem:

basicconveyor = A reference to the conveyor.

item = A reference to the flowitem.

startpoint = The starting location for the flowitem as measured from the beginning of the conveyor, along the conveyor's length to the flowitem's edge furthest from the head of the conveyor (the leading edge if the conveyor's direction is forward, the trailing edge if the conveyor's direction is backward).

startspeed = The initial speed the flowitem will begin traveling at.

targetspeed = The target speed the flowitem will try to achieve. If the targetspeed is greater than the startspeed, then the flowitem will accelerate up to the target speed; otherwise it will decelerate down to the target speed. If both the startspeed and the targetspeed are set to 0, the flowitem will be positioned at the startpoint, and will not move.

accdec = The acceleration or deceleration used to achieve the target speed over time. A value of 0 indicates infinite acceleration/deceleration; or in other words the flowitem will reach it's targetspeed immediately.

No destination or termination speed is required, because the flowitems continue traveling along the conveyor until they either reach the end of the conveyor, run into another flowitem, or their convey state is changed again. The BasicConveyor allows multiple "Decision Points" to be defined along its length. These trigger points are convenient locations to update the convey state of a flowitem. In addition to the main convey state kinematic assigned to the flowitem with the bcsetitemconveystate() command, a flowitem has two other kinematic structures associated with it that may be used to apply custom kinematic motion (translation or rotation) in addition to the travel motion along the conveyor. One of the kinematic structures is based on simulated time units, and the other is based on distance units along the length of the conveyor. To access these kinematic structures, use the bcgetitemkinematics() command, then use the initkinematics() and addkinematic() commands to create the custom kinematic motion desired. See bcgetitemkinematics() command documentation for more information.
Example
bcsetitemconveystate(current, item, position, 0, 60, 0);
Deprecated, use Math.ceil()
Description
This command is deprecated. Use Math.ceil() instead.

Gets the smallest integral value not less than num.
Example
Deprecated, use Table.cell()
Description
This command is deprecated. Use Table.cell() instead.

Gets a reference to the table's cell.
Example
double val = getnodenum(cellrc(reftable("MyTable"),2,3));
Deprecated, use conveyor.targetSpeed
Example
changeconveyorspeed(current, 4);
This example changes the conveyor's speed to 4.
Deprecated, use Object.input.close()
Description
This command is deprecated. Use Object.input.close() instead.

This command blocks the input of the object. Only the input ports themselves, or the input in general needs to be closed to block entry. When port connections are displayed with sufficient size in the view window, you will see a small red bar drawn across all the input ports (squares) for the object, signifying the input ports are blocked. Individual ports may still be open and drawn in green, but entry to the object is still blocked because of the red bar. Compare this command with stopinput().
Example
if (current.subnodes.length == getvarnum(current,"maxcontent")
closeinput(current);

This blocks the input ports of current when it has too many objects inside it.
Deprecated, use Object.output.close()
Description
This command is deprecated. Use Object.output.close() instead.

This command blocks the output of the object. Only the output ports themselves, or the output in general needs to be closed to block the exit. When port connections are displayed with sufficient size in the view window, you will see a small red bar drawn across all the output ports (squares) for the object, signifying the output ports are blocked. Individual ports may still be open and drawn in green, but exit from the object is still blocked because of the red bar. Compare this command with stopoutput().
Example
if (current.subnodes.length == current.mincontent)
closeoutput(current);

This blocks the output ports of current, if current has too few objects inside it.
Copies thenode into the specified container
Description
This command is deprecated. Use treenode.copy() instead.

Copy thenode into the node specified as container. This command is different from createinstance() in that it does not attempt to establish any links between thenode and any class. If an instantiation is required, use createinstance() instead.

If samename is 1, the copy will have the same name as thenode.

If samename is 0, the newly created node's name will be thenode's name with a random number added to the end.

If inobject is 1, the copy will be created in the object data portion of the container. If the container does not have object data, the command does nothing.

If cached is 1, a pre-cached version of the node will be copied. This is generally faster.

If replace is 1, the copy will overwrite container, instead of being placed inside it.

If those parameters are not specified, they default to 0.
Example
createcopy(Model.find("Tools/FlowItemBin/7/1"), current)
Description
This command is deprecated. Use Object.create() instead.

For developer use.

This command creates an instance of the class specified as class and places it in the object specified as location. The instance will be given a name that is the name of the class followed by a number. The instance will have all of the variables and attributes of class and it's superclasses. Nodes in the behavior node will not be copied into the instance, as they apply to all instances of the class. The object passed as class should be in the library. Generally, location is the model. The library and the model can be easily referenced using the library() and model() commands.
Example
createinstance(library().find("?Source"), model());
This creates an instance of the Source class in the model.
Deprecated, use Process Flow instead
Description
This command is deprecated. Use Process Flow instead.

This command creates a task sequence on the object specifies as dispatcher that causes it to send a message to the object specified as receiver. The OnMessage trigger of the receiving object will be executed when the message is sent. The values passed as param1, param2, and param3 will be available in the trigger function using the param() command. This task sequence will be given a priority of priority and a preempting value of preempting. The possible values for preempting are:

0 - PREEMPT_NOT
1 - PREEMPT_ONLY
2 - PREEMPT_AND_ABORT_ACTIVE
3 - PREEMPT_AND_ABORT_ALL
Example
createsendmessagetask(current, current.centerObjects[1],1,PREEMPT_NOT,5, 6, 7);
Deprecated, use Process Flow instead
Description
This command is deprecated. Use Process Flow instead.

This command creates a task sequence for the object specified by dispatcher that causes it to travel to the point specified by xlox, y, and z. Once the object reaches that point, it will wait in the state specified as state until an endwaittask() command is issued to it. For a list of legal states, see setstate(). If relativeloc is 1, the specified point is relative to the origin of dispatcher. If relativeloc is 0, the specified point is the exact point in

the model that dispatcher will try to travel to. It will travel until its front edge reaches the specified point. This task sequence will be given a priority of priority and a preempting value of preempting. The possible values for preempting are:

0 - PREEMPT_NOT
1 - PREEMPT_ONLY
2 - PREEMPT_AND_ABORT_ACTIVE
3 - PREEMPT_AND_ABORT_ALL
Example
createtraveltolocandwaittask(current.centerObjects[1], 1, 5.15, 2.5, 0, 0, STATE_IDLE, 1, PREEMPT_NOT);
Deprecated, use Process Flow instead
Description
This command is deprecated. Use Process Flow instead.

This command creates a task sequence for the object specified by dispatcher that causes it to travel to the point specified by xlox, y, and z. If relativeloc is 1, the specified point is relative to the origin of dispatcher. If relativeloc is 0, the specified point is the exact point in the model that dispatcher will try to travel to. It will travel until its front edge reaches the specified point. This task sequence will be given a priority of priority and a preempting value of preempting. The possible values for preempting are:

0 - PREEMPT_NOT
1 - PREEMPT_ONLY
2 - PREEMPT_AND_ABORT_ACTIVE
3 - PREEMPT_AND_ABORT_ALL
Example
createtraveltoloctask(current.centerObjects[1], 1, 5.15, 2.5, 0, 0, 1, PREEMPT_NOT);
Deprecated, use Process Flow instead
Description
This command is deprecated. Use Process Flow instead.

This command creates a task sequence on the object specified as dispatcher that causes the object to not perform new task sequences that it is given until it has been released. The object can be released with the endwaittask() command. The object will be in the state specified by state while it is waiting. For a list of possible states, see setstate() command. This task sequence will be given a priority of priority and a preempting value of preempting. The possible values for preempting are:

0 - PREEMPT_NOT
1 - PREEMPT_ONLY
2 - PREEMPT_AND_ABORT_ACTIVE
3 - PREEMPT_AND_ABORT_ALL
Example
createwaittask(current.centerObjects[1], STATE_IDLE, 1, PREEMPT_NOT);
Deprecated, use treenode.labels["LabelName"].destroy()
Description
This command is deprecated. Use treenode.labels["LableName"].destroy() instead.

Deletes the specified label from the node called "labels" on the specified object.
The specified label can either be the labelname as a string or the label's rank as a number.
If the label does not exist in that node, this command does nothing.
Example
dellabel(current,"MyLabel")
Deprecated, use Table.query()
Description
This command is deprecated. Use Table.query() instead.

Dumps the full result table for the last call to query() into a node. If asTable is 1, it will dump the result as table data. If asTable is 0, it will dump it as bundle data.
Example
Reads an Excel range and dumps it to a treenode
Description
This function is overloaded so that it has two functions depending on which arguments you pass in. The first (where you pass in a string) is deprecated. Use excelrangereadnum() and excelrangereadstr() instead.

The second (where you pass in a treenode) will read a range in Excel and assign all of the data in that range to the target treenode. If the treenode has bundle data, the excel data will be set on the bundle. Otherwise, subnodes will be inserted under the target treenode that will have the Excel data set on them as either string or number data, in the same format as Global Tables.

The origin of the range is specified by the row and col passed in, and the second pair of numbers will specify the size of the range. If 0 is passed in for any one of these, Flexsim will automatically choose the boundary in that direction of the Excel range that has data.

Flags can be passed in to change exactly what is read from Excel. Those flags are EXCEL_DATA_AUTOMATIC, EXCEL_DATA_NUMBER, EXCEL_DATA_STRING, EXCEL_DATE_AS_NUM, EXCEL_USE_COLUMNHEADERS and EXCEL_USE_ROWHEADERS.

EXCEL_DATA_AUTOMATIC will assign string or number data based on what the datatype of the Excel cell is. This is the default behavior.

EXCEL_DATA_NUMBER will force all Excel data to be read as a number.

EXCEL_DATA_STRING will force all Excel data to be read as a string.

EXCEL_DATE_AS_NUM will read any Excel dates as numbers readable by Flexsim as dates. Otherwise, the data will come in as a string.

EXCEL_USE_COLUMNHEADERS will take the first row of data and use it as names for the table columns instead of data.

EXCEL_USE_ROWHEADERS will take the first column of data and use it as names for the table rows instead of data.

Example
treenode myTable = node ("Tools/GlobalTables/GlobalTable1>variables/data", model());

excelrangeread(myTable, 1, 1, 5, 0, EXCEL_DATA_AUTOMATIC | EXCEL_USE_COLUMNHEADERS);

This will read data from the active sheet starting at cell A1. It will read the first five rows, and read as many columns as have data in them. The first row will be used as names for the columns of the Global Table we're writing to. Therefore, if the Excel sheet has 10 columns with data in them, a total of 40 nodes will be inserted under the data variable of the Global Table. Each of those nodes will have the datatype of their corresponding Excel cell.
Reads data from a source table node and writes it to the active Excel sheet
Description
This function will write all the of the data from the source table node to the active Excel sheet. If the treenode has bundle data, this will read the bundle and write it to the sheet, otherwise it will look for child nodes with data on them, like a Global Table. The row and col passed in specify where on the Excel sheet to begin writing the data. All of the data on the source node will always be written. Flags can be passed in to change the use of headers. Those flags are EXCEL_USE_COLUMNHEADERS and EXCEL_USE_ROWHEADERS.

EXCEL_USE_COLUMNHEADERS will write any existing column headers as a separate row in the Excel table.

EXCEL_USE_ROWHEADERS will write any existing row headers as a separate column in the Excel table.
Example
treenode myTable = node("Tools/GlobalTables/GlobalTable1>variables/data", model());

excelrangewrite(myTable, 1, 1, EXCEL_USE_ROWHEADERS | EXCEL_USE_COLUMNHEADERS);

This will take all of the data in GlobalTable1 and write it to the active Excel sheet, starting at cell A1. Before it writes any of the actual data, there will be a row of column headers and column of row headers.
Description
This command is deprecated. Use the Group class instead.

Create a new family (a list of nodes used for organizing relational information).
Example
familycreate(item,"family1")
Description
This command is deprecated. Use the Group class instead.

Returns a pointer to a member of the specified family.
Example
familymember(item,"family1",2)
Description
This command is deprecated. Use the Group class instead.

Adds a new family member to the specified familycontainer.
Example
familymemberadd(item,"family1",item.subnodes[1])
Description
This command is deprecated. Use the Group class instead.

Removes a family member from the specified familycontainer.
Example
familymemberdel(item,"family1",item.subnodes[2])
Description
This command is deprecated. Use the Group class instead.

Returns the size of the specified family.
Example
familymemberqty(item,"family1")
Deprecated, use the Array class
Description
This command is deprecated. Use the Array class to construct the array using an array literal: Array arr = [1, 2, 3];

Fill a local array with values.
Example
Description
Performs a matching test a defined number of times, and when a match is found, returns a user-definable value associated with that match. Within the match expression and return expression, "count" can be used to determine which iteration your are on in the check. This can be used to search in a list of things for a matching item or criterion. If returnexpression is not included in the call, then findmatch() will return the count associated with the matching expression. If no matches are found, findmatch() will return 0. If reverseorder is 1, then it will go backwards, assigning count to nr first, then nr - 1, etc. down to 1. If returnexpression is left out, then findmatch will return the count associated with the found match.
Example
int portNr = findmatch(current.outObjects.length, current.outObjects[count].subnodes.length < 5);
This example will return the output port number that corresponds to the first object it finds connected to current's output ports that has a content less than 5.

treenode object = findmatch(current.outObjects.length, current.outObjects[count].subnodes.length < 5, current.outObjects[count]);
This example is similar to the previous example except it will return the object itself instead of the associated port number.

int item2Rank = findmatch(current.subnodes.length, current.subnodes[count].type == 2);
This example will return the rank number of the first item found in current's queue that has an item type of 2.

Description
Iteratively evaluates an expression, and then returns the maximum value found, or a user-definable return value associated with that maximum value. Within the value expression, return expression and criterion, "count" can be used to determine which iteration you are on in the check. If the return expression is not defined, the maximum value found will be returned. Additionally, you can specify a criterion to filter out values as invalid. If criterion is defined and nothing meets the criterion, 0 will be returned.
Example
double latestCreation = findmax(current.subnodes.length, getcreationtime(current.subnodes[count]));
This example will return the maximum creation time of all items in current.

int largestQueuePortNr = findmax(current.inObjects.length, current.inObjects[count].subnodes.length;
This example will return the input port number associated with the object with the largest queue of items.

int largestQueuePortNr = findmax(current.inObjects.length, current.inObjects[count].subnodes.length, count, getitemstate(current.inObjects[count].first) == FR_STATE_READY);
This example is the same as the previous example, but additionally in includes a criterion that the first item in the upstream object must also have been released.

Deprecated, use Math.floor()
Description
This command is deprecated. Use Math.floor() instead.

Gets the largest integral value not greater than num.
Example
Deprecated, use Object.stats.input.value
Description
This command is deprecated. Use Object.stats.input.value instead.

Returns the input statistic of the involved object.
Example
double inval = getinput(current.centerObjects[1]);
Deprecated
Description
This command is deprecated. Returns one of the values from the movement record that is passed in as the first parameter to the function. This record is the return value from a call to getmoverecord(). The value passed to this function as the second parameter indicates which value from the movement record the user wishes to retrieve:
0 = The record ID. This is the record\'s row number in the movement table.
1 = The ItemID of the flowitem whose movement is recorded by the record.
2 = The time the flowitem moved.
3 = The object that the flowitem moved from. This is returned as an int and should be converted to a treenode using tonode().
4 = The object that the flowitem moved to. This is returned as an int and should be converted to a treenode using tonode();
5 = The itemtype of the flowitem at the time it moved.
Example
See the example for getnummoverecords().
Deprecated, use Table.query()
Description
This command is deprecated. Use Table.query() instead.

Returns the number of columns in the result table for the last call to query().
Example
Deprecated, use Table.query()
Description
This command is deprecated. Use Table.query() instead.

Returns the total number of rows in the result table for the last call to query()
Example
Deprecated, use Table.query()
Description
This command is deprecated. Use Table.query() instead.

Returns the source table's row number associated with a matched row in the last query() result.

table - If a string, it is the name of the table as defined in the FROM statement. If you used an alias, it should be the table's alias. If a number, it should be the 1-based index of the table in the FROM statement. If there is only one table in the query, this should be 1. For multiple tables, the first table in the FROM is 1, the second is 2, etc.
matchRow - The 1-based row of the result table of the query.

Note that this command will not work if you use aggregator functions such as MIN(), MAX(), AVG(), etc. in the SELECT clause. When aggregators are used, this command just returns the number of rows in the source table.
Example
Deprecated, use Table.query()
Description
This command is deprecated. Use Table.query() instead.

Returns a value in the result table for the last call to query()

row - The 1-based row number of the result table
col - The 1-based column number of the result table, or the name of the result column. If you have defined aliases in the select statement, the column name should be the alias.
Example
Deprecated, use treenode.rank
Description
This command is deprecated. Use treenode.rank instead.

Gets the rank of a child node in its parent's sub-tree.
Example
Deprecated, use Object.stats.state().value
Description
This command is deprecated. Use Object.stats.state().value instead.

Returns the state of an object in numeric form.
Example
getstatenum(current);
Deprecated, use Object.stats.state().valueString
Description
This command is deprecated. Use Object.stats.state().valueString instead.

Returns the state of an object as a text string.
Example
getstatestr(current);
Deprecated, use Object.inObjects[]
Description
This command is deprecated. Use Object.inObjects[] instead.

Reference the upstream object connected to a downstream object's input port.
Example
Deprecated, use the Array class
Description
This command is deprecated. Use the Array class instead.

Index of occurrence of value in list. The list, of length qty, is searched and the position in the list of the value val is returned by this function.
Example
listinlist(5,3,2,1,2,3,4)

This returns the index number 4 because 3 is the fourth number in the list of 5 numbers.
Deprecated, use the Array class
Description
This command is deprecated. Use the Array class instead.

Index of highest value. The list, of length qty, is searched and the position in the list of the highest value is returned by this function.
Example
listmax(5,2,1,2,3,4)

This returns a 5 because 4 is the largest value and it is fifth in the list of five numbers.
Deprecated, use the Array class
Description
This command is deprecated. Use the Array class instead.

Highest value. The list, of length qty, is searched and the value of the highest value is returned by this function.
Example
listmaximum(5,2,1,2,3,4)

This returns a 4 because it is the highest value in the list.
Deprecated, use the Array class
Description
This command is deprecated. Use the Array class instead.

Average of values. The mean of the values in the list, of length qty, is returned by this function.
Example
listmean(5,2,1,2,3,4)

This returns 2.5.
Deprecated, use the Array class
Description
This command is deprecated. Use the Array class instead.

Index of lowest value. The list, of length qty, is searched and the position in the list of the lowest value is returned by this function.
Example
listmin(5,2,1,2,3,4)

This returns 2 because 1 is the lowest value and it is second in the list.
Deprecated, use the Array class
Description
This command is deprecated. Use the Array class instead.

Lowest value. The list, of length qty, is searched and the value of the lowest value is returned by this function.
Example
listminimum(5,2,1,2,3,4)

This returns 1 because that is the lowest value in the list.
Deprecated, use Array class
Description
This command is deprecated. Use the Array class instead.

Allocate general purpose local array with the given quantity of local variables.
Type can be: 1 = num, 2 = str, 3 = coupling, 4 = obj. May only be used in flexscript.
Example
localarray(1,4)
Returns a random sample from a lognormal distribution
Description
lognormal() and lognormal2() are similar functions, but with different parameter definitions. lognormal() uses parameter definitions as defined on wikipedia and other sites. lognormal2() uses parameters as defined in the latest versions of Expertfit. Essentially, the parameters can be converted as follows:

lognormal( location, normalmean, normalstdev ) = lognormal2( location, Math.exp( normalmean ), normalstdev )
lognormal2( location, scale, shape ) = lognormal( location, Math.log( scale ), shape ) (Math.exp(x) is e raised to the x power, and Math.log(x) is the natural logarithm of x.)

Please make sure you use the right distribution. Using the wrong distribution could result in bad simulation results.

lognormal( location, normalmean, normalstdev, stream ) is a continuous probability distribution.

Inputs:
location : ( - , )
normalmean such that ( Math.exp( normalmean ) > 0 )
normalstdev such that ( normalstdev > 0 )
stream is a reference to one of FlexSim's random number streams {0,1,2,...}

Outputs:
range = ( location , )
mean = location + Math.exp( normalmean + normalstdev² 2)
variance = Math.exp( 2*normalmean + normalstdev² ) [ Math.exp( normalstdev² ) − 1 ]

Probability Density Functions:



Possible Applications:
Used to model the time to perform some task, and to model quantities that are the product of a large number of other quantities. It can also be used as a rough model in the absence of data.

Comments:
The probability density for the lognormal distribution takes on shapes similar to gamma( normalstdev, normalmean ) and weibull( normalstdev, normalmean ) densities for normalstdev > 1, but can have a large spike close to x=0 that is often useful.
Example
Returns a random sample from a lognormal distribution
Description
This command is an alternative to the lognormal2 command, used in the absence of data. You can specify the mean and standard deviation, and the command will calculate from those parameters the proper location, scale, and shape parameters for the lognormal2 command, and return a sample from that distribution. Note that the shape of the distribution is pre-defined to be a bell-shaped curve with a reasonably long right tail. Hence this command isn't as flexible as the lognormal2 command. This command, similar to the triangular distribution, should be used in the absence of data, where you know the mean and standard deviation of the distribution, and you assume that the distribution is right-skewed (it has a longer right tail), but you do not have a real data set to fit to a distribution. Refer to lognormal2 for more information. Relating to the diagram describing the lognormal2 distribution, the lognormalmeanstdev command uses a normalstdev/shape value of 0.75 to define its shape. Note that since the shape of the distribution is hard-set, depending on the mean and standard deviation values, this may return a negative value.
Example
double cycletime = lognormalmeanstdev(10, 2);
This example will return a random value that follows a right-skewed lognormal distribution with a mean of 10 and standard deviation of 2.
Deprecated, use the Array class
Description
This command is deprecated. Use Array(qty) instead. Array array = Array(4);

Initializes a local array.
Example
Deprecated, use Table.sort()
Description
This command is deprecated. Use Table.sort() instead.

Sorts the table by each column (ascending for positive columns, descending for negative columns).
Example
Deprecated, use kinematics instead
Description
This command is deprecated. Use kinematics instead.

Causes the object to travel to a given rz and return the simulation time that it will arrive. Similar to the travelto command, but includes a start and end speed definition. Used in the development of the TaskExecuter.
Example
ntravelto(current, 0, 5, 8, 0, 1, 1, 1, 0, 1)
Deprecated, use kinematics instead
Description
This command is deprecated. Use kinematics instead.

Updates the rz of an object after a ntravelto() command was called on it. Used in the OnPreDraw of the TaskExecuter to update it's position.
Example
ntraveltoupdate(current)
Deprecated, use Object.input.open()
Description
This command is deprecated. Use Object.input.open() instead.

This command unblocks the input of the object after it has been previously blocked with the closeinput() command. It is necessary that both the input ports themselves, and the input in general, are open before entry will be allowed. It is advised that modelers never use this command in any field other than the OnMessage field which has been triggered with the senddelayedmessage() command, because commands which open ports often spawn several other activities that shouldn't be performed during transitional events. Compare this command with resumeinput().
Example
if (current.subnodes.length < maxcontent)
openinput(current);
Deprecated, use Object.output.open()
Description
This command is deprecated. Use Object.output.open() instead.

This command unblocks the output of the object after it has been previously blocked with the closeoutput() command. It is necessary that both the output ports themselves, and the output in general, are open before exiting is allowed. It is advised that modelers never use this command in any field other than the OnMessage field which has been triggered with the senddelayedmessage() command, because commands which open ports often spawn several other activities that shouldn't be performed during transitional events. Compare this command with resumeoutput().
Example
if (current.subnodes.length > mincontent)
openoutput(current);
Deprecated, use Object.outObjects[]
Description
This command is deprecated. Use Object.outObjects[] instead.

Reference the downstream object connected to an upstream object's output port.
Example
Deprecated, use Object.attrs[]
Description
This command is deprecated. Use the treenode.attrs's [] operator instead.

Gets a reference to the ranked node in the object's attribute sub-tree at rank.
Example
Deprecated, use Table("GlobalTableName")
Description
This command is deprecated. Use the Table class instead.

Gets a reference to a global table.
Example
Table table = reftable("GlobalTable1")
Deprecated, use Vec3.project()
Description
This command is deprecated. Use Vec3.project() instead.

This command returns the x, y, or z location of an object relative to an object that contains it. The containerobj does not need to be the immediate container, but does need to eventually be a container of the object. Use a coordinate value of 1,2,3 for x,y,z respectively.
Example
double x = relloc(current,model(),1);
double y = relloc(current,model(),2);
double z = relloc(current,model(),3);

Sets x, y and z to the x,y,z positions of the current object relative to the model space.
Deprecated, use Object.input.resume()
Description
This command is deprecated. Use Object.input.resume() instead.

This command opens the input of an object just like openinput() does, but because it keeps track of previous stopinput() commands called on the object, it will only open input after all stops have been resumed. Refer to openinput() documentation for additional information.
Example
resumeinput(current.centerObjects[1]);
Deprecated, use Object.resume()
Description
This command is deprecated. Use Object.resume() instead.

Tells the object that it may resume whatever it was doing before stopobject() was called on it.
The id value is optional and is for matching stop requests with resume requests. Refer to the stopobject()
documentation for more information on this.
Example
resumeobject(current.centerObjects[1]);
Deprecated, use Object.output.resume()
Description
This command is deprecated. Use Object.output.resume() instead.

This command opens the output of an object just like openoutput() does, but because it keeps track of previous stopoutput() commands called on the object, it will only open output after all stops have been resumed. Refer to openoutput() documentation for additional information.
Example
resumeoutput(current.centerObjects[1]);
Deprecated, use user libraries
Description
This command is deprecated. Use user libraries instead.

This saves the node to disk as a service pack file (.fpk).
A save file dialog box will appear, allowing you to define the path and name of the file. A service pack is nothing more than a node with subnodes. The first subnode is assumed to be toggled flexscript and contain string data with code. When the service pack is loaded using File | Install Service Pack, the first subnode of you service pack will execute automatically. The code will usually copy the other subnodes into the MAIN and VIEW trees.
Example
savefpk(so());
Deprecated, use Object.setLocation()
Description
This command is deprecated. Use Object.setLocation() instead.

Sets the x, y, and z location of the object's rotational center, relative to its container.
Example
Deprecated, use treenode.rank
Description
This command. Use treenode.rank instead.

Sets the rank of a child node in its parent's sub-tree.
Example
Description
This command is deprecated. Use Object.stats.state().valueString = stateStr;

For development use. Set the state of an object using the actual name of one of the states. The state names must be as they appear in a state pie chart.
Example
setstate_s(current,"busy")
Deprecated, use the Model class
Description
This command is deprecated. Use Model.statisticalTime instead.

Returns the current simulation time with respect to when stats were last reset, such as since the warmup time has passed in an experiment or since resetstats() was executed.
Example
item.TimeIn = statisticaltime();

This sets the label called "TimeIn" on the object referenced by item to the current simulation clock time.
Deprecated, use Object.input.stop()
Description
This command is deprecated. Use Object.input.stop() instead.

This command closes the input of the object just like closeinput() does, but it also keeps track of consecutive stopinput() commands, and will only open input after all stops have been resumed. Refer to closeinput() documentation for additional information.
Example
stopinput(current.centerObjects[1]);
Deprecated, use Object.stop()
Description
This command is deprecated. Use Object.stop() instead.

Tells the object to stop whatever it is doing, go into the state specified (in the state profile if specified), and waits for resumeobject() to be called. Stopobject commands are accumulated, meaning if stopobject is called twice on the same object, the object will not resume its operations until resumeobject has been called twice as well. Stopping an object depends on the type of object that is being stopped.

For FixedResources, generally events are delayed indefinitely, input and output is stopped, and all operations going into and out of the object are stopped. This means that TaskExecuters trying to load/unload to or from the object will have to wait until the object has been resumed.

For TaskExecuters, events are not delayed, but rather a preempting task sequence with priority of 100,000 is created for the TaskExecuter, with one TE_STOP task in it.

Be aware that, if there are several stop requests for the same object, the state for each stop request is not remembered. If an object is requested to stop by entity A with state 12, and then is later requested to stop by entity B for state 14, it will go into state 14 and forget state 12. Even if entity B resumes the object before entity A, the object will remain in state 14 until all stop requests have resumed.

The last two parameters, id and priority, are optional and have recently been added to fix the problem in the previous paragraph. If you specify these parameters, then it will store a record of the stop request, instead of just incrementing a value for the number of stops requested. The id is like a key for that stop request. The priority allows the object to prioritize its stop requests. For example, if you have a stop request for the scheduled down state, and another for the breakdown state at the same time, technically the object should be in two states at once, but since a FlexSim object can only be in one state at a time, the priority value breaks the tie and goes into the state of the highest priority stop request.

The id value should match an id value that is added to a resumeobject() command later on. This is for matching stop requests with their appropriate resume requests. For example, if you stop an object for scheduled maintenance with and id of 1, once the scheduled maintenance is finished, you will need to resume the object with the same id of 1.
Example
stopobject(current.centerObjects[1], STATE_BLOCKED);
Deprecated, use Object.output.stop()
Description
This command is deprecated. Use Object.output.stop() instead.

This command closes the output of the object just like closeoutput() does, but it also keeps track of consecutive stopoutput() commands, and will only open output after all stops have been resumed. Refer to closeoutput() documentation for additional information.
Example
stopoutput(current.centerObjects[1]);
Deprecated, use string.substr()
Description
This command is deprecated. Use string.substr() instead.

Returns a substring of string defined by index start (base 1) and length.
Example
Deprecated, use string.substr()
Description
This command is deprecated. Use string.substr() instead.

This command will return a portion of a string. The new string is defined with a starting character number and a length. A start value of 0 refers to the first character in the original string.
Example
stringpart("Hello",2,3) returns the sub string "llo".
Deprecated, use string.replace()
Description
This command is deprecated. Use string.replace() instead.

Returns a copy of stringtosearch with all occurrences of searchfor replaced with replacewith.
Example
Deprecated, use the Model class
Description
This command is deprecated. Use Model.time instead.

Returns the current simulation time.
Example
item.TimeIn = time();

This sets the label called "TimeIn" on the object referenced by item to the current simulation clock time.
Deprecated, use treenode.up
Description
This command is deprecated. Use treenode.up to set the node's parent (container).

This command moves movenode into the container node. This is like the moveobject command, except no events (ie. OnSend, OnReceive) are executed.
Example
transfernode(current.labels["inactivequeue"].first, current.labels["activequeue"]);
Deprecated, use Object.getLocation()
Description
This command is deprecated. Use Object.getLocation().

Gets the x location of the rotational center of the object within its container.
Example
Deprecated, use Object.getLocation()
Description
This command is deprecated. Use Object.getLocation() instead.

Gets the y location of the rotational center of the object within its container.
Example
Deprecated, use Object.rotation
Description
This command is deprecated. Use Object.rotation instead.

Gets the y rotation of an object (rotation about the y-axis).
Example
Deprecated, use Object.getLocation()
Description
This command is deprecated. Use Object.getLocation() instead.

Gets the z location of the rotational center of the object within its container.
Example
Deprecated, use Object.rotation
Description
This command is deprecated. Use Object.rotation instead.

Gets the z rotation of an object (rotation about the z-axis).
Example

Development

High-level development commands not typically intended for end users.
Description
For developer use. Set a maintenance switch.

The first parameter designates the operation. The second parameter designates a state to set it to.

Maintenance switches:
0. print this list
1. deadlinks
2. atttrbute bind method (0=names, 1=indices, 2=bootstrap)
3. numberprecision
4. display binding report
5. usercollisions
6. post-onsend
7. loadsavemode
8. disablefscheck
9. disablefspreprocess
10. splinetension
11. streamalizer
12. immediately load extended docs
13. save reps at experiment end
14. suppress object library compile
15. suppress global compile
16. set runtime info
17. get runtime info
18. bind c++ functions
19. autorebind c++ functions onoff
20. get presentation mode
21. refresh main menu
22. is optquest enabled
23. flypaths in seconds units
24. chached ports on/off
25. bind on reset on/off
26. set category name (user command group is 22, other 23, 24+ is available)
27. object sizermode 0. default 1. 3-axis
28. show hidden nodes in tree
29. hide 3d cursor
30. supress simclock redraw
31. use parser two
32. grid draw settings: bitwise field: 0x1-auto expand grid, 0x2-show grid axes, 0x4-show grid origin
1000. DDE
Example
maintenance(0)
Description
For developer use. This gives direct access to the Windows API PostMessage() command, posting a message to a window. Use windowfromnode() or getviewhwnd() to get access to the window handle. Refer to Windows API documentation for more information. Not that you cannot use a message that uses lParam or wParam as an [out] parameter, or one that you pass in as a pointer to a struct. You should be able to pass strings into lParam or wParam, but again thay cannot be [out] parameters. FlexSim does not include all possible WM_ messages in its flexscript macros, so if you want to use one in flexscript, you will need to find the definition in the windows header files and add the definition to your flexscript code.
Example
postwindowmessage(windowfromnode(view), WM_COPY, 0,0);
Description
For developer use. This gives direct access to the Windows API SendMessage() command, sending a message to a window. Use windowfromnode() or getviewhwnd() to get access to the window handle. Refer to Windows API documentation for more information. Not that you cannot use a message that uses lParam or wParam as an [out] parameter, or one that you pass in as a pointer to a struct. You should be able to pass strings into lParam or wParam, but again thay cannot be [out] parameters. FlexSim does not include all possible WM_ messages in its flexscript macros, so if you want to use one in flexscript, you will need to find the definition in the windows header files and add the definition to your flexscript code.
Example
sendwindowmessage(windowfromnode(view), WM_COPY, 0,0);
Description
For developer use. This command queries the joystick or controller state or sets functionality for a joystick or controller.

stickno defines an id for the joystick or gamepad you want to query. This is a number between 0 and 32. Usually you will only have one joystick connected to your computer, so in this case you should use the value 1 as stickno. If you are using a gamepad, you might need to use stickno 2. For Xbox controllers, stickno will be a value between 0 and 3. For VR controllers, stickno will be either 0 or 1. For Oculus touch controllers, stickno 0 is the left hand and stickno 1 is the right hand. Use stickno -1 to get the status, position, or rotation of a connected VR headset.

command defines the operation that the command should perform. This should be one of the macros below:

STICK_JOY_STATUS - Queries the connectivity of the joystick. If the joystick is connected properly, then this command will return 0. If the return value is non-zero, then there is some error with the joystick's connectivity, and you can view the system console to see what the error is. The following errors apply:
    MMSYSERR_NODRIVER - The joystick driver is not present.
    MMSYSERR_INVALPARAM - Invalid joystick ID or hwnd is NULL.
    JOYERR_NOCANDO - Cannot capture joystick input because a required service (such as a Windows timer) is unavailable.
    JOYERR_UNPLUGGED - The specified joystick is not connected to the system.
    JOYERR_PARMS - Invalid joystick ID or hwnd is NULL.

STICK_JOY_XPOS - Current X-coordinate of the joystick. This is a number between 0 and 65535. 0 means the joystick is pushed all the way to the left, 65535 means it is pushed all the way to the right, and 32768 is exactly in the center. If you are using a gamepad, then this is the x position of the left side joystick.

STICK_JOY_YPOS - Current Y-coordinate of the joystick. Again this is a number between 0 and 65535. 0 is up, 65535 is down. If you are using a gamepad, this is the position of the gamepad's left joystick.

STICK_JOY_ZPOS - Current Z-coordinate of the joystick. If you are using a joystick, this will usually be the current setting of the joystick's throttle. Again it is a value between 0 and 65535. If you are using a gamepad, this represents the y position of the right side joystick.

STICK_JOY_BUTTONS - Current state of the 32 joystick buttons. This is bitwise integer with each bit representing the state of a given button. For a joystick, the main trigger button is usually represented by the 0x00000001 bit, other buttons on the stick are 0x00000002 and 0x00000004, and buttons on the base of the joystick are then higher order bits. You will need to test these out on your own as each joystick is a little different.

STICK_JOY_SET_CAPTURE - This command sets the joystick capture to a FlexSim window that you specify. This command requires the win and p parameters to be passed in. By executing this command, joystick messages will be sent to the OnStick attribute of the view. For example, if you have an ortho view that you would like to listen to joystick events, you would call this command, passing the ortho view's HWND handle (use windowfromnode()), and a polling period. The period specifies a time interval in milliseconds to repeatedly call the OnStick event. If p is 0, then the OnStick event will only be called when the joystick's state changes. If p is greater than 0, then the OnStick event will simply be called at the end of each sample period interval. Example: stick(1,5, windowfromnode(sv()), 200); This will cause the OnStick event to be called every 200 milliseconds. In order for this to work, you need to add an OnStick attribute to the view (you may also need to rebind the view's attributes after adding it: right-click->Edit|Rebind Object Attributes).

STICK_JOY_RELEASE_CAPTURE - This command releases the joystick capture for the window that was previously captured with the 5 command. You need to pass in the win parameter as with command 5.

STICK_JOY_RPOS - Current position of the rudder or fourth joystick axis of the joystick. For a joystick, this is usually the rotation of the joystick if your joystick can rotate around its z axis. Again it is a number between 0 and 65535. If you are using a gamepad, it is the x position of the right side joystick.

STICK_JOY_UPOS - Current fifth axis position of the joystick.

STICK_JOY_VPOS - Current sixth axis position of the joystick.

STICK_JOY_POV - Current position of the point-of-view control of the joystick. It is a number between 0 and 35900 and represents the number of degrees times 100. For a gamepad, this represents the directional pad on the left of the gamepad. Up is 0, right is 9000, down is 18000, left is 27000. If the directional pad is not pressed, the value will be 65535. If you are using a joystick, there may be a directional thumb controller on the stick itself that you can press up, down, right, or left, and this will get the setting of that controller.

STICK_JOY_CURRENT_BUTTON - Current button number that is pressed.

STICK_JOY_FLAGS - Flags indicating the valid information returned about the joystick.

STICK_XBOX_STATUS - Queries the connectivity of the Xbox controller. If the controller is connected properly, this returns 0.

STICK_XBOX_BUTTONS - Bitmask of the device digital buttons. A set bit indicates that the corresponding button is pressed.

STICK_XBOX_LEFT_THUMB_X - Left thumbstick x-axis value. Each of the thumbstick axis members is a signed value between -32768 and 32767 describing the position of the thumbstick. A value of 0 is centered. Negative values signify down or to the left. Positive values signify up or to the right.

STICK_XBOX_LEFT_THUMB_Y - Left thumbstick y-axis value. The value is between -32768 and 32767.

STICK_XBOX_RIGHT_THUMB_X - Right thumbstick x-axis value. The value is between -32768 and 32767.

STICK_XBOX_RIGHT_THUMB_Y - Right thumbstick y-axis value. The value is between -32768 and 32767.

STICK_XBOX_LEFT_TRIGGER - The current value of the left trigger analog control. The value is between 0 and 255.

STICK_XBOX_RIGHT_TRIGGER - The current value of the right trigger analog control. The value is between 0 and 255.

STICK_VR_STATUS - Returns 1 if an Oculus Rift controller is active. Returns 2 if an HTC Vive controller is active. Returns 0 if the controller is inactive. Returns nullvar if the controller is not attached.

STICK_VR_THUMB_X - Thumbstick or trackpad x-axis value between -1 and 1.

STICK_VR_THUMB_Y - Thumbstick or trackpad y-axis value between -1 and 1.

STICK_VR_INDEX_TRIGGER - Index trigger value between 0 and 1.

STICK_VR_GRIP_TRIGGER - Grip trigger value between 0 and 1. On HTC Vive, grip button is pressed.

STICK_VR_BUTTON_1 - The first button is pressed. A or X on Oculus Rift. Unused on HTC Vive.

STICK_VR_BUTTON_2 - The second button is pressed. B or Y on Oculus Rift. Unused on HTC Vive.

STICK_VR_BUTTON_3 - The third button is pressed. Enter or Home on Oculus Rift. Menu on HTC Vive.

STICK_VR_BUTTON_4 - The fourth button is pressed. Thumbstick on Oculus Rift. Trackpad on HTC Vive.

STICK_VR_TOUCH_BUTTON_1 - The first button is touched. Unused on HTC Vive.

STICK_VR_TOUCH_BUTTON_2 - The second button is touched. Unused on HTC Vive.

STICK_VR_TOUCH_BUTTON_3 - The third button is touched. Unused on Oculus Rift.

STICK_VR_TOUCH_BUTTON_4 - The fourth button is touched.

STICK_VR_TOUCH_THUMB_REST - The thumb rest sensor is touched on Oculus Rift. Unused on HTC Vive.

STICK_VR_TOUCH_INDEX_TRIGGER - The index trigger sensor is touched.

STICK_VR_TOUCH_POINTING - The hand gesture is pointing on Oculus Rift. Unused on HTC Vive.

STICK_VR_TOUCH_THUMB_UP - The hand gesture is thumbs-up on Oculus Rift. Unused on HTC Vive.

STICK_VR_HAND_POSITION - The controller position in VR space.

STICK_VR_HAND_ROTATION - The controller rotation in VR rotation coordinates.

STICK_VR_HAND_WORLD_POSITION - The controller position in FlexSim world space.

STICK_VR_HAND_WORLD_ROTATION - The controller rotation in FlexSim rotation coordinates.

STICK_VR_HAND_OFFSET_POSITION - The controller's position in FlexSim world space, but with an offset applied based on the controller's rotation. Pass an array as the offset vector in the p parameter. You can use this option to get a point relative to the controller, such as a finger position or where the controller is pointing.

STICK_VR_TARGET_FLOOR_POSITION - The target position on the floor that the controller is pointing towards. Pass a value in the p parameter for the maximum distance away from the controller.

STICK_VR_SET_VIBRATION - Causes the controller to vibrate. On Oculus Rift, pass an array for the p parameter where the first element is a value between 0 and 1 for the frequency and the second element is a value between 0 and 1 for the amplitude. On HTC Vive, pass a duration in microseconds for the p parameter.

STICK_VR_SUBMIT_VIBRATION - Causes the controller to subtly vibrate. On original Oculus Touch controllers, pass an array of amplitudes (0 - 255) for the p parameter to be queued up and executed. Unused on HTC Vive or Oculus Rift S controllers.
Example
stick(1, STICK_JOY_YPOS); This gets the y position of the joystick id 1

Drawing

Commands associated with drawing graphics in the planar, orthographic, or perspective views. Draw commands are designed for use in OnDraw events such as the "Custom Draw Code" field found in an object's Properties window.
Draws a 3D column
Description
A very versatile command that can draw anything with multiple sides and a height such as a square, a pentagon, a pyramid, and even a cylinder (if the total number of sides is large).

Draws a column with its origin (center of base) positioned at x, y, z. The column is then defined by the number of sides, a base radius, a top radius, and a height. The column can be rotated in degrees about each axis with rx, ry, rz. The color is defined by the red, green, blue color components ranging from 0 to 255.

An optional opacity parameter will change the column from clear (0) to opaque (1). If a valid textureindex number is entered, then the associated image will be repeated textureXrepeat and textureYrepeat times on each face of the column.

The location, size and rotation of the column are by default relative to the object it is drawn on. The parameters shown in brackets [ ] must ALL be used or ALL not used. The textureindex is a numeric value that can be learned using the gettextureindex() command or through the Tools | Media Files menu.
Example
drawcolumn(0,0,0, 5 ,4,2, 6 ,0,0,0, 175,175,175, .6, 3, 5,1);
Draws a 3D cube
Description
Draws a cube with its origin (bottom left corner) positioned at x, y, z. Its length, width, and height is defined by sx, sy, and sz respectively. It can be rotated in degrees about the x, y, and z axis by rx, ry, and rz. The color is defined by the red, green, blue color components ranging from 0 to 255.

An optional opacity parameter will change the cube from clear (0) to opaque (1). If a valid textureindex number is entered, then the associated image will be repeated textureXrepeat and textureYrepeat times on each face of the cube.

The location, size and rotation of the cube are by default relative to the object it is drawn on. The optional parameters shown in brackets [ ] must ALL be used or ALL not used. The textureindex is a numeric value that can be learned using the gettextureindex() command or through the Tools | Media Files menu.
Example
drawcube(0,0,0, 5,3,2, 0,0,0, 175,175,175, .6, 3, 1,1);
Draws a 3D clyinder
Description
This command draws a hollow cylinder with its origin (center of base) positioned at x, y, z. The cylinder's dimensions are defined by a base radius, a top radius and a height. Use the drawdisk() command to cap off the ends of the cylinder. The cylinder can be rotated in degrees about the x, y, and z axis by rx, ry, and rz. The color is defined by the red, green, blue color components ranging from 0 to 255.

An optional opacity parameter will change the cylinder from clear (0) to opaque (1). If a valid textureindex number is entered, then the associated image will be used as texturing around the outside circumference of the cylinder.

The location, size and rotation of the cylinder are by default relative to the object it is drawn on. The optional parameters shown in brackets [ ] must ALL be used or ALL not used. The textureindex is a numeric value that can be learned using the gettextureindex() command or through the Tools | Media Files menu.
Example
drawcylinder(0,0,0, 1,1, 5, 0,0,0, 175,175,175, .6,3);
Draw a 3D disk
Description
Draws a flat planar disk with its origin (center of radius) positioned at x, y, z. The disk's dimensions are defined by an inner radius, an outer radius, a start angle, and a sweep angle. A sweep angle of 360 makes a complete circle. An innerradius greater than 0 will create a disk with a hole in the middle of it. The disk can be rotated in degrees about the x, y, and z axis by rx, ry, and rz. The color is defined by the red, green, blue color components ranging from 0 to 255.

An optional opacity parameter will change the disk from clear (0) to opaque (1). If a valid textureindex number is entered, then the associated image will be used as texturing across the face of the disk.

The location, size and rotation of the disk are by default relative to the object it is drawn on. The optional parameters shown in brackets [ ] must ALL be used or ALL not used. The textureindex is a numeric value that can be learned using the gettextureindex() command or through the Tools | Media Files menu.
Example
drawdisk(0,0,0, .5,2, 90,270, 0,0,0, 175,175,175, 1,3);
Description
This command can only be used in a 3D view. It draws a texture-mapped text string. This uses the same functionality that draws the names and stats below objects. If scaled correctly, it draws a very crisp, readable text. Use this in conjunction with setdrawnamefunction() to customize the data that is shown in the box below objects. Unlike drawtext(), this command's parameter set is much more stripped down, so you should use gl commands (i.e. fglTranslate(), fglScale(), fglColor(), etc.) to set up the location, size, and render settings before drawing the text.
Example
Add the following code to an object's Custom Draw Code trigger:

if(!param(2)) {
	setdrawnamefunction(80, 15, c, param(1), 1);
} else {
	fglTranslate(-40, -15, 0);
	drawflattext("Hello World");
}
	
This will draw the text Hello World in the display box below the object
Draws a planar quadrilateral
Description
This command draws a planar quadrilateral with vertices defined by x1, y1, z1, x2, y2, z2, x3, y3, z3, x4, y4, and z4. The color is defined by the red, green, blue color components ranging from 0 to 1. The resultant shape and lighting is dependent on the order or sequence in which the vertices are defined. If vertices are all in one plane, consider using drawrectangle() command.
Example
drawquad(view, 0, 0, 1, 0, 0, 0, 2, 2, 2, 4, 5, 6, 1, 0, 0);

This example draws a quadrilateral with vertices defined by the following four points: (0,0,0), (1,0,0), (2,2,2), and (4,5,6). The quadrilateral will be red in color.
Draw a 3D rectangle
Description
Draws a flat planar rectangle with a user-defined location, length, width, rotation, and color. The drawquad() command must be used to draw a rectangle that is not parallel with the x, y or z plane.

An optional opacity parameter will change the rectangle from clear (0) to opaque (1). If a valid textureindex number is entered, then the associated image will be repeated textureXrepeat and textureYrepeat times across the face of the rectangular plane as texturing.

The location, size and rotation of the rectangle are by default relative to the object it is drawn on. The optional parameters shown in brackets [ ] must ALL be used or ALL not used. The textureindex is a numeric value that can be learned using the gettextureindex() command or through the Tools | Media Files menu.
Example
drawrectangle(0,0,0, 2,3, 0,0,0, 175,175,175, .6, 1, 2,3);
Draw a 3D sphere
Description
Draws a hollow sphere with its origin (center of sphere) positioned at x, y, z. The sphere's dimensions are defined by a single radius. The color is defined by the red, green, blue color components ranging from 0 to 255.

An optional opacity parameter will change the sphere from clear (0) to opaque (1). If a valid textureindex number is entered, then the associated image will be wrapped over the surface of the sphere as a texture.

The location, size and rotation of the sphere are by default relative to the object it is drawn on. The optional parameters shown in brackets [ ] must ALL be used or ALL not used. The textureindex is a numeric value that can be learned using the gettextureindex() command or through the Tools | Media Files menu.
Example
drawsphere(0,0,0,5,175,175,175,1,3);
Draws text
Description
This command draws text at a location defined by x, y, and z. The width parameter is not used. The text width and height is determined by the height parameter. The rotation is defined by rx, ry, and rz. The color is defined by the red, green, blue color components ranging from 0 to 1. You can define the flags parameter as follows: 0x1 = bold, 0x2 = italic, 0x4 = underline. The flags parameter only applies to non-3d views The opacity if used should be a number ranging between 0 (full transparency) to 1 (opaque). Call drawfont() command to change font type before calling drawtext() if desired. This command can be used in a planar, 3D, graph or panel view.
Example
drawtext(view, "Hello", 0,0,0, 0,.3,.1, 90,0,0, 1,0,0, .8);

This example draws "Hello" at location (0,0,0) with size 0.3, thickness 0.1, rotation (90,0,0), an rgb color (1,0,0), and opacity of 0.8.
Enables an OpenGL draw setting
Description
Enables an OpenGL draw setting. Note that for optimization purposes, FlexSim's drawing engine does not automatically restore the enabled/disabled state of a given setting, so it is up to you, if you use this command, to restore the setting to its default after you have executed your drawing functionality. Failing to restore a setting to its default will result in weird rendering of other objects in the model.

Common OpenGL draw settings:
GL_LIGHTING
    Turns lighting on and off.
    Turn it on if polygons do not change color when they turn away from the viewer.
    Default: enabled.
GL_CULL_FACE
    Turns back-face culling on and off
    Turn it off if you want both sides (front and back) of all polygons drawn.
    Default: disabled.
GL_TEXTURE_2D
    Turns texturing on and off.
    Turn it off if a texture is being displayed and you don't want it there.
    Default: enabled.

You can refer to standard OpenGL documentation on glEnable() for more information if needed.
Example
fglEnable(GL_LIGHTING);