Variant

Description

A type that can hold either a number, a string, a treenode or an Array.

The Variant class is an essential type by which data is exchanged between various functionalities in FlexSim. As such, the Variant represents a "jack of all trades" that can hold several different types of data. It can be a number type, holding a number value. It can be a string type, holding text data. It can be a treenode type, holding a reference to a node in FlexSim's tree. It can be an Array type, holding an array of Variants. It can be a Map type, holding a set of keys and their associated values. And finally, it can be a null variant meaning it is none of the other types.

Method/Property Forwarding

Since the Variant is just a flexible container for other data types, its methods and properties are just forwarders to the various methods and properties of the types that the Variant holds. For example, if you have a Variant holding a treenode, you can use all of the methods and properties on a treenode directly on the Variant without having to cast to a treenode with the as() keyword.

Variant node = param(1);
node.name = "Object1";
node.value = 5;

The only property that is exclusive to the Variant is type, which tells you what type of data is held by a Variant. All other properties and methods simply forward to the associated method or property of the held class. If the Variant does not hold the associated type, then calling the type's method will result in an exception. For example, if a Variant has a number, and you call the find() method on it, FlexScript will throw an exception.

Casting

Variant will cast to any of its target types without throwing an exception. If the Variant does not hold the target type, it will just give a null-or-similar result. This means a NULL treenode, empty string, empty Array, or 0.0 number.

Variant num = 1;
string asString = num; // empty string
Variant str = "Hello";
double asNum = str; // 0.0

To determine the type of data that is held by a Variant, use the type property, or use the is() keyword.

Variants as Objects

If a variant holds a treenode with Object data, it can access Object properties and methods. However, the type property is simply a treenode type. In order to test if a Variant holds an Object node, you can use the is() keyword:

Variant obj = param(1);
if (obj.is(Object)) {
	obj.location = Vec3(1, 2, 3);
}
Variants as Arrays

The Variant implements special logic associated with arrays in that you can treat a Variant like an Array even if it does not hold array data. If a Variant holds, for example, a string, you can treat the Variant as if it were a 1-length Array with a string as its first element.

Variant val = "Hello";
int len = val.length; // len = 1
return val[len]; // returns "Hello";

Also, if you cast a Variant into a non-array type, and the Variant is in fact an Array, the cast operation will return the first element of the array. Thus you can even treat an Array Variant as a non-array type.

Variant myArray = ["Hello", "World"];
string myString = myArray;
return myString; // returns "Hello"

These capabilities are especially useful in Process Flow, where you are often dealing with label values that may or may not contain array data, but you want to interface with those data in a consistent manner.

Variants as Maps

To use a Variant as a Map, you can use the dynamic properties of the Variant:

// adds the key "Key1" with the value 3 to the map
mapVariant.Key1 = 3 

No other methods or properties of the Map are accessible from the Variant. To use them, you'll need to cast the Variant as a Map:

Map map = mapVariant;
// now you can access map methods and properties
Array keys = map.keys;

Null Values

To check if a Variant is null you can compare the value with the special keyword nullvar or compare its type with the VAR_TYPE_NULL macro.

Variant val;
val == nullvar //true
val.type == VAR_TYPE_NULL // true

Where this gets more complicated is when dealing with treenode type Variants returned by other properies. See the discussion of treenode null values.

Other data types do not have null types but have an empty type that corresponds to that type:

string emptyString = "";
int emptyInt = 0;
double emptyDouble = 0.0;
Array emptyArray = [];
Awaitable

A Variant is awaitable, meaning it can be the predicate of an await statement. This will only cause suspension of the coroutine if the Variant is a reference to a Coroutine node that has been suspended. You can get a reference to a coroutine node by calling treenode. coevaluate() on a node that itself contains an await statement. Awaiting any other type of Variant value will do nothing.

Properties

animations Returns the animations property of an Object Variant.
attrs Returns the attrs property of an Object Variant.
centerObjects Returns the centerObjects property of an Object Variant.
color Returns the color property of an Object Variant.
dataType Gets/sets the dataType property on a treenode Variant.
first Gets the first subnode of a treenode Variant.
flags Returns the flags property of an Object Variant.
inObjects Returns the inObjects property of an Object Variant.
input Returns the input property of an Object Variant.
labels Accesses the labels of a treenode Variant, or the string keys of a Map variant.
last Gets the last subnode of a treenode Variant.
length Gets/sets the Array length of a Variant.
location Returns the location property of an Object Variant.
name Gets/sets the name of a treenode Variant.
next Gets the next node of a treenode Variant.
outObjects Returns the outObjects property of an Object Variant.
output Returns the output property of an Object Variant.
prev Gets the next node of a treenode Variant.
rank Gets/sets the rank of a treenode Variant.
resetPosition Returns the resetPosition property of an Object Variant.
rotation Returns the rotation property of an Object Variant.
size Returns the size property of an Object Variant.
stats Returns the stats property of an Object Variant.
subnodes Accesses the subnodes of a treenode Variant.
type Gets a Variant's type, one of VAR_TYPE_NUMBER, VAR_TYPE_STRING, VAR_TYPE_NODE, or VAR_TYPE_ARRAY
up Gets/sets the parent of a treenode Variant.
value Gets/sets the data value of a treenode Variant.

Methods

append Appends another Variant to this Variant.
byteToCharIndex Returns the index of a given byte in a string Variant.
charAt Returns the character at a given byte index in a string Variant.
charToByteIndex Returns the byte index associated with a specific character index in a string Variant.
clone Clones a Variant.
concat Concatenates two Variants into an Array.
copy Creates a new copy of a treenode Variant.
destroy Destroys a treenode Variant.
endsWith Queries whether a string Variant ends with a defined string.
evaluate Evaluates a treenode Variant
fill Fills an Array Variant with a defined value.
find Finds a node in a treenode Variant's sub-tree by path.
getLocation Gets an Object Variant's location.
getPath Gets the path of a treenode Variant.
getVariable Gets the value of an Object Variant's variable.
includes Queries whether a string Variant includes a string.
indexOf Gets the index of an element in an Array Variant.
join Joins an Array Variant into a string.
match Matches a reqular expression on a string Variant.
message Send a message to the Object Variant.
padEnd Pads the end of a string Variant with the padString to the given length.
padStart Pads the start of a string Variant with the padString to the given length.
pop Pops an element from an Array Variant.
push Pushes a value onto an Array Variant.
repeat Repeats a string Variant a number of times.
replace Replaces text in a string Variant
resume Return the Object Variant to its state prior to stop().
reverse Reverses an Array Variant
search Searches a string Variant for an internal string or pattern.
setLocation
setRotation Sets the Object Variant's rotation.
setSize Sets the Object Variant's size.
setState Sets the Object Variant's state.
setVariable Sets the value of an Object Variant's variable.
shift Shifts (pops) an element from the front of an Array Variant.
slice Returns a new Array made up of a subsection of an Array Variant.
splice Removes and/or inserts elements into an Array Variant.
split Splits a string Variant into an Array.
startsWith Queries if a string Variant starts with a defined string.
stop Stops the Object Variant, sets its state, and waits for resume().
substr Extracts a section of a string Variant and returns a new string.
toLowerCase Creates a lower case string from a string Variant.
toNum Interprets a string Variant's content as a floating point number.
toUpperCase Creates an upper case string from a string Variant.
trim Trims white space off of the ends of a string Variant.
unshift Unshifts (pushes) a value onto the front of an Array Variant.

Operators

- Subtracts two numbers.
-- Decrements a number Variant.
! Tests if a Variant is either a null Variant, a NULL treenode, or a 0.0 number.
!= Tests if a Variant is not equal to another value.
% Returns the modulus of two numbers.
* Multiplies two numbers.
/ Divides two numbers.
[] Accesses an element of an Array Variant.
+ Adds two numbers.
++ Increments a number Variant
+= Increments a number Variant by a defined value, or appends a string to the current string Variant.
< Tests if a Variant is less than a number.
<= Tests if a Variant is less than or equal to a number.
-= Decrements a number Variant by a defined value.
== Tests if two values are equal to each other.
> Tests if a Variant is greater than a number.
>= Tests if a Variant is greater than or equal to a number.

Details

Do no remove, this fixes the anchor on doc.flexsim.com

Variant.animations

readonly animations

Description

Returns the animations property of an Object Variant.

This property throws an exception if the Variant is not a treenode with Object data.
Do no remove, this fixes the anchor on doc.flexsim.com

Variant.attrs

readonly attrs

Description

Returns the attrs property of an Object Variant.

This property throws an exception if the Variant is not a treenode with Object data.
Do no remove, this fixes the anchor on doc.flexsim.com

Variant.centerObjects

readonly centerObjects

Description

Returns the centerObjects property of an Object Variant.

This property throws an exception if the Variant is not a treenode with Object data.
Do no remove, this fixes the anchor on doc.flexsim.com

Variant.color

readonly Color color

Description

Returns the color property of an Object Variant.

This property throws an exception if the Variant is not a treenode with Object data.
Do no remove, this fixes the anchor on doc.flexsim.com

Variant.dataType

int dataType

Description

Gets/sets the dataType property on a treenode Variant.

An exception is thrown if the Variant is not a treenode type.

Do no remove, this fixes the anchor on doc.flexsim.com

Variant.first

treenode first

Description

Gets the first subnode of a treenode Variant.

Forwards to treenode.first. An exception is thrown if the Variant is not a treenode type.

Do no remove, this fixes the anchor on doc.flexsim.com

Variant.flags

readonly flags

Description

Returns the flags property of an Object Variant.

This property throws an exception if the Variant is not a treenode with Object data.
Do no remove, this fixes the anchor on doc.flexsim.com

Variant.inObjects

readonly inObjects

Description

Returns the inObjects property of an Object Variant.

This property throws an exception if the Variant is not a treenode with Object data.
Do no remove, this fixes the anchor on doc.flexsim.com

Variant.input

readonly input

Description

Returns the input property of an Object Variant.

This property throws an exception if the Variant is not a treenode with Object data.
Do no remove, this fixes the anchor on doc.flexsim.com

Variant.labels

readonly labels

Description

Accesses the labels of a treenode Variant, or the string keys of a Map variant.

Forwards to treenode.labels, or to the Map.stringKeys. An exception is thrown if the Variant is not a treenode or Map type.

Do no remove, this fixes the anchor on doc.flexsim.com

Variant.last

treenode last

Description

Gets the last subnode of a treenode Variant.

Forwards to treenode.last. An exception is thrown if the Variant is not a treenode type.

Do no remove, this fixes the anchor on doc.flexsim.com

Variant.length

int length

Description

Gets/sets the Array length of a Variant.

If the Variant is already an Array type, this will forward to Array.length. If the Variant is a null Variant, length will return 0. If it is a number, string, or treenode type, length will return 1.

Variant myVar; // initialized as null Variant
myVar.length; // returns 0
myVar = 5; // set to number type
myVar.length; // returns 1

If length is set, the Variant will convert itself into an Array, and forward to Array.length

Variant myArray = "Hello";
myArray.length = 2; // converts to Array and sets Array length to 2.
Do no remove, this fixes the anchor on doc.flexsim.com

Variant.location

readonly Vec3 location

Description

Returns the location property of an Object Variant.

This property throws an exception if the Variant is not a treenode with Object data.
Do no remove, this fixes the anchor on doc.flexsim.com

Variant.name

string name

Description

Gets/sets the name of a treenode Variant.

Forwards to treenode.name. An exception is thrown if the Variant is not a treenode type.

Do no remove, this fixes the anchor on doc.flexsim.com

Variant.next

readonly treenode next

Description

Gets the next node of a treenode Variant.

Forwards to treenode.next. An exception is thrown if the Variant is not a treenode type.

Do no remove, this fixes the anchor on doc.flexsim.com

Variant.outObjects

readonly outObjects

Description

Returns the outObjects property of an Object Variant.

This property throws an exception if the Variant is not a treenode with Object data.
Do no remove, this fixes the anchor on doc.flexsim.com

Variant.output

readonly output

Description

Returns the output property of an Object Variant.

This property throws an exception if the Variant is not a treenode with Object data.
Do no remove, this fixes the anchor on doc.flexsim.com

Variant.prev

readonly treenode prev

Description

Gets the next node of a treenode Variant.

Forwards to treenode.prev. An exception is thrown if the Variant is not a treenode type.

Do no remove, this fixes the anchor on doc.flexsim.com

Variant.rank

int rank

Description

Gets/sets the rank of a treenode Variant.

Forwards to treenode.rank. An exception is thrown if the Variant is not a treenode type.

Do no remove, this fixes the anchor on doc.flexsim.com

Variant.resetPosition

readonly resetPosition

Description

Returns the resetPosition property of an Object Variant.

This property throws an exception if the Variant is not a treenode with Object data.
Do no remove, this fixes the anchor on doc.flexsim.com

Variant.rotation

readonly Vec3 rotation

Description

Returns the rotation property of an Object Variant.

This property throws an exception if the Variant is not a treenode with Object data.
Do no remove, this fixes the anchor on doc.flexsim.com

Variant.size

readonly Vec3 size

Description

Returns the size property of an Object Variant.

This property throws an exception if the Variant is not a treenode with Object data.
Do no remove, this fixes the anchor on doc.flexsim.com

Variant.stats

readonly stats

Description

Returns the stats property of an Object Variant.

This property throws an exception if the Variant is not a treenode with Object data.
Do no remove, this fixes the anchor on doc.flexsim.com

Variant.subnodes

readonly subnodes

Description

Accesses the subnodes of a treenode Variant.

Forwards to treenode.subnodes. An exception is thrown if the Variant is not a treenode type.

Do no remove, this fixes the anchor on doc.flexsim.com

Variant.type

readonly int type

Description

Gets a Variant's type, one of VAR_TYPE_NUMBER, VAR_TYPE_STRING, VAR_TYPE_NODE, or VAR_TYPE_ARRAY

Do no remove, this fixes the anchor on doc.flexsim.com

Variant.up

treenode up

Description

Gets/sets the parent of a treenode Variant.

Forwards to treenode.up. An exception is thrown if the Variant is not a treenode type.

Do no remove, this fixes the anchor on doc.flexsim.com

Variant.value

Variant value

Description

Gets/sets the data value of a treenode Variant.

Forwards to treenode.value. An exception is thrown if the Variant is not a treenode type.

Do no remove, this fixes the anchor on doc.flexsim.com

Variant.append()

Variant append( Variant val )

Parameters

val The value to append to this Variant.

Returns

Variant The modified Variant

Description

Appends another Variant to this Variant.

If this Variant is already an Array, this forwards to Array.append(). If the Variant is a null Variant, it will become val. If it is a non-array type, it will convert itself into an Array, and forward to Array.append().

Do no remove, this fixes the anchor on doc.flexsim.com

Variant.byteToCharIndex()

int byteToCharIndex( int byteIndex )

Parameters

byteIndex The 1-based byte index of the target character.

Returns

int The 1-based character index of the character.

Description

Returns the index of a given byte in a string Variant.

Forwards to string.byteToCharIndex. An exception is thrown if the Variant is not a string type.
Do no remove, this fixes the anchor on doc.flexsim.com

Variant.charAt()

string charAt( int byteIndex )

Parameters

byteIndex The 1-based byte index of the target character.

Returns

string The target character, as a string.

Description

Returns the character at a given byte index in a string Variant.

Forwards to string.charAt. An exception is thrown if the Variant is not a string type.
Do no remove, this fixes the anchor on doc.flexsim.com

Variant.charToByteIndex()

int charToByteIndex( int charIndex )

Parameters

charIndex The 1-based character index of the target character.

Returns

int The 1-based byte index of the character.

Description

Returns the byte index associated with a specific character index in a string Variant.

Forwards to string.charToByteIndex. An exception is thrown if the Variant is not a string type.
Do no remove, this fixes the anchor on doc.flexsim.com

Variant.clone()

Variant clone( )

Returns

Variant A clone of the Variant.

Description

Clones a Variant.

If the Variant is an Array type, this forwards to Array.clone(). Otherwise it just returns a copy of its value.

Do no remove, this fixes the anchor on doc.flexsim.com

Variant.concat()

Array concat( Array other )

Parameters

other The Array to concatenate onto the end of this Variant.

Returns

Array The resulting Array.

Description

Concatenates two Variants into an Array.

Forwards to Array.concat().

Do no remove, this fixes the anchor on doc.flexsim.com

Variant.copy()

treenode copy( treenode destination = 0 , int replace = 0 )

Description

Creates a new copy of a treenode Variant.

Forwards to treenode.copy(). An exception is thrown if the Variant is not a treenode type.

Do no remove, this fixes the anchor on doc.flexsim.com

Variant.destroy()

destroy( )

Description

Destroys a treenode Variant.

Forwards to treenode.destroy(). An exception is thrown if the Variant is not a treenode type.

Do no remove, this fixes the anchor on doc.flexsim.com

Variant.endsWith()

int endsWith( string str )

Description

Queries whether a string Variant ends with a defined string.

Forwards to string.endsWith(). An exception is thrown if the Variant is not a string type.

Do no remove, this fixes the anchor on doc.flexsim.com

Variant.evaluate()

Variant evaluate( )
Variant evaluate( Variant p1 ... p20 )

Parameters

p1-p20 The parameters to pass to the evaluation.

Description

Evaluates a treenode Variant

Forwards to treenode.evaluate(). An exception is thrown if the Variant is not a treenode type.

Do no remove, this fixes the anchor on doc.flexsim.com

Variant.fill()

Variant fill( Variant value )

Description

Fills an Array Variant with a defined value.

Forwards to Array.fill(). If the Variant is not already an Array, it simply sets its value to the passed value.

Do no remove, this fixes the anchor on doc.flexsim.com

Variant.find()

treenode find( string path )

Description

Finds a node in a treenode Variant's sub-tree by path.

Forwards to treenode.find(). An exception is thrown if the Variant is not a treenode type.

Do no remove, this fixes the anchor on doc.flexsim.com

Variant.getLocation()

Vec3 getLocation( double xFactor , double yFactor , double zFactor )
Vec3 getLocation( Vec3 factors )

Parameters

xFactor The x value of the point on the object where the location will be measured from. Measured as a percent of the object's size (0-1).
yFactor The y value of the point on the object where the location will be measured from. Measured as a percent of the object's size (0-1).
zFactor The z value of the point on the object where the location will be measured from. Measured as a percent of the object's size (0-1).
factors A vector representing the point on the object where the location will be measured from. Measured as a percent of the object's size (0-1).

Returns

Vec3 A vector holding the object's location

Description

Gets an Object Variant's location.

Forwards to Object.getLocation. This method throws an exception if the Variant is not a treenode with Object data.
Do no remove, this fixes the anchor on doc.flexsim.com

Variant.getPath()

string getPath( treenode relativeTo = 0 , int byName = 1 )

Description

Gets the path of a treenode Variant.

Forwards to treenode.getPath(). An exception is thrown if the Variant is not a treenode type.

Do no remove, this fixes the anchor on doc.flexsim.com

Variant.getVariable()

Variant getVariable( string variableName )

Parameters

variableName The name of the variable

Returns

Variant The value of the specified variable.

Description

Gets the value of an Object Variant's variable.

Forwards to Object.getVariable. This method throws an exception if the Variant is not a treenode with Object data.
Do no remove, this fixes the anchor on doc.flexsim.com

Variant.includes()

int includes( string str )

Description

Queries whether a string Variant includes a string.

Forwards to string.includes(). An exception is thrown if the Variant is not a string type.

Do no remove, this fixes the anchor on doc.flexsim.com

Variant.indexOf()

int indexOf( Variant )

Description

Gets the index of an element in an Array Variant.

Forwards to Array.indexOf(). If the Variant is not an Array, it is treated as an array of length 1.

Do no remove, this fixes the anchor on doc.flexsim.com

Variant.join()

string join( string separator = 0 )

Description

Joins an Array Variant into a string.

Forwards to Array.join(). If the Variant is not already an Array, it will create a new Array from itself, and call join on that Array.

Do no remove, this fixes the anchor on doc.flexsim.com

Variant.match()

Description

Matches a reqular expression on a string Variant.

Forwards to string.match(). An exception is thrown if the Variant is not a string type.

Do no remove, this fixes the anchor on doc.flexsim.com

Variant.message()

Variant message( double delayTime = 0 , treenode fromObj = 0 , Variant p1 = nullvar , Variant p2 = nullvar , Variant p3 = nullvar )

Parameters

delayTime Optional. Specifies the amount of time to delay before firing the message. If -1, the message will be sent synchronously. If 0 or greater, an event will be created in the defined delay time, and the message will be fired after that delay time.
fromObj Optional. The object that is sending the message. This can be accessed from the message trigger.
p1 Optional. Defines the first parameter of the message. This can be accessed from the message trigger as msgparam1.
p2 Optional. Defines the second parameter of the message. This can be accessed from the message trigger as msgparam2.
p3 Optional. Defines the third parameter of the message. This can be accessed from the message trigger as msgparam3.

Returns

Variant If the message is sent synchronously (delay = -1), it will return whatever is returned by the object's message trigger. If the message is sent asynchronously (delay >= 0), the call will return a reference to the event node that was created in the event list.

Description

Send a message to the Object Variant.

Forwards to Object.message. This method throws an exception if the Variant is not a treenode with Object data.
Do no remove, this fixes the anchor on doc.flexsim.com

Variant.padEnd()

string padEnd( int targetLength , string padString )

Parameters

targetLength The desired length of the padded string.
padString The string used to pad the current string.

Returns

string The string padded to the specified length.

Description

Pads the end of a string Variant with the padString to the given length.

Forwards to string.padEnd. An exception is thrown if the Variant is not a string type.
Do no remove, this fixes the anchor on doc.flexsim.com

Variant.padStart()

string padStart( int targetLength , string padString )

Parameters

targetLength The desired length of the padded string.
padString The string used to pad the current string.

Returns

string The string padded to the specified length.

Description

Pads the start of a string Variant with the padString to the given length.

Forwards to string.padStart. An exception is thrown if the Variant is not a string type.
Do no remove, this fixes the anchor on doc.flexsim.com

Variant.pop()

Variant pop( )

Description

Pops an element from an Array Variant.

Forwards to Array.pop(). If the Variant is not an Array, it will convert itself into a null Variant, and return its original value.

Do no remove, this fixes the anchor on doc.flexsim.com

Variant.push()

Variant push( Variant value )

Returns

Variant The modified Variant.

Description

Pushes a value onto an Array Variant.

Forwards to Array.push(). If the Variant is a non-array value, it will convert itself into an Array, and forward to Array.push(). If it is a null Variant, it will become the passed value (not an Array).

Do no remove, this fixes the anchor on doc.flexsim.com

Variant.repeat()

string repeat( int numRepeats )

Description

Repeats a string Variant a number of times.

Forwards to string.repeat(). An exception is thrown if the Variant is not a string type.

Do no remove, this fixes the anchor on doc.flexsim.com

Variant.replace()

string replace( string findStr , string replaceWith )

Parameters

findStr
replaceWith
findPattern

Description

Replaces text in a string Variant

Forwards to string.replace(). An exception is thrown if the Variant is not a string type.

Do no remove, this fixes the anchor on doc.flexsim.com

Variant.resume()

resume( int id = 0 , int stateProfile = 0 )

Parameters

id Optional. For matching stop requests with resume requests.
stateProfile Optional. The state profile on which to record the state.

Description

Return the Object Variant to its state prior to stop().

Forwards to Object.resume. This method throws an exception if the Variant is not a treenode with Object data.
Do no remove, this fixes the anchor on doc.flexsim.com

Variant.reverse()

Variant reverse( )

Description

Reverses an Array Variant

Forwards to Array.reverse(). If the Variant is a non-array value, it will convert itself into an Array, and forward to Array.push(). If it is a null Variant, it will become the passed value (not an Array).

Do no remove, this fixes the anchor on doc.flexsim.com

Variant.setLocation()

Object setLocation( double x , double y , double z )
Object setLocation( double x , double y , double z , double xFactor , double yFactor , double zFactor )
Object setLocation( Vec3 loc , Vec3 factors )

Parameters

x The desired x position.
y The desired y position.
z The desired z position.
xFactor The x value of the point on the object where the location will be measured from. Measured as a percent of the object's size (0-1).
yFactor The y value of the point on the object where the location will be measured from. Measured as a percent of the object's size (0-1).
zFactor The z value of the point on the object where the location will be measured from. Measured as a percent of the object's size (0-1).
loc A vector holding the desired position.
factors A vector representing the point on the object where the location will be measured from. Measured as a percent of the object's size (0-1).

Returns

Object The translated object.

Description

Forwards to Object.setLocation. This method throws an exception if the Variant is not a treenode with Object data.
Do no remove, this fixes the anchor on doc.flexsim.com

Variant.setRotation()

Object setRotation( double x , double y , double z )
Object setRotation( Vec3 rotation )

Parameters

x The desired rotation about the x axis.
y The desired rotation about the y axis.
z The desired rotation about the z axis.
rotation A vector of the desired rotation values.

Returns

Object The rotated object.

Description

Sets the Object Variant's rotation.

Forwards to Object.setRotation. This method throws an exception if the Variant is not a treenode with Object data.
Do no remove, this fixes the anchor on doc.flexsim.com

Variant.setSize()

Object setSize( double x , double y , double z )

Parameters

x The desired x size.
y The desired y size.
z The desired z size.

Returns

Object The sized object.

Description

Sets the Object Variant's size.

Forwards to Object.setSize. This method throws an exception if the Variant is not a treenode with Object data.
Do no remove, this fixes the anchor on doc.flexsim.com

Variant.setState()

setState( int state , int profile )

Parameters

state The desired state.
profile The desired state profile.

Description

Sets the Object Variant's state.

Forwards to Object.setState. This method throws an exception if the Variant is not a treenode with Object data.
Do no remove, this fixes the anchor on doc.flexsim.com

Variant.setVariable()

setVariable( string variableName , Variant value )

Parameters

variableName The name of the variable.
value The desired variable value.

Description

Sets the value of an Object Variant's variable.

Forwards to Object.setVariable. This method throws an exception if the Variant is not a treenode with Object data.
Do no remove, this fixes the anchor on doc.flexsim.com

Variant.shift()

Variant shift( )

Description

Shifts (pops) an element from the front of an Array Variant.

Forwards to Array.shift(). If the Variant is not an Array, it will convert itself into a null Variant, and return its original value.

Do no remove, this fixes the anchor on doc.flexsim.com

Variant.slice()

Array slice( int fromIndex , int toIndex )

Description

Returns a new Array made up of a subsection of an Array Variant.

Forwards to Array.slice(). If the Variant is not an Array, it will create an Array from itself and forward to Array.slice().

Do no remove, this fixes the anchor on doc.flexsim.com

Variant.splice()

Variant splice( int fromIndex , int removeCount )
Variant splice( int fromIndex , int removeCount , Array insertArray )

Returns

Variant The modified Variant

Description

Removes and/or inserts elements into an Array Variant.

Forwards to Array.splice(). If the Variant is not an Array, it will make itself into an Array and forward to Array.splice().

Do no remove, this fixes the anchor on doc.flexsim.com

Variant.split()

Array split( string delimiter , int limit = -1 )

Description

Splits a string Variant into an Array.

Forwards to string.split(). An exception is thrown if the Variant is not a string type.

Do no remove, this fixes the anchor on doc.flexsim.com

Variant.startsWith()

int startsWith( string str )

Description

Queries if a string Variant starts with a defined string.

Forwards to string.startsWith(). An exception is thrown if the Variant is not a string type.

Do no remove, this fixes the anchor on doc.flexsim.com

Variant.stop()

stop( int stopState , int id = 0 , double priority = 0 , int stateProfile = 0 )

Parameters

stopState The state the object will go into.
id Optional. For matching stop requests with resume requests.
priority Optional. For breaking ties between stop() calls.
stateProfile Optional. The state profile on which to record the state.

Description

Stops the Object Variant, sets its state, and waits for resume().

Forwards to Object.stop. This method throws an exception if the Variant is not a treenode with Object data.
Do no remove, this fixes the anchor on doc.flexsim.com

Variant.substr()

string substr( int startIndex , int length )

Parameters

startIndex The 1-based byte index of the first character to extract. If this index is in the middle of a multi-byte character, it will extract the full character. If it is a negative number, the start position is string.length + beginIndex, or in other words it is an offset from the end of the string.
length The length of the target string, in bytes.

Returns

string The extracted string.

Description

Extracts a section of a string Variant and returns a new string.

Forwards to string.substr. An exception is thrown if the Variant is not a string type.
Do no remove, this fixes the anchor on doc.flexsim.com

Variant.toLowerCase()

string toLowerCase( )

Description

Creates a lower case string from a string Variant.

Forwards to string.toLowerCase(). An exception is thrown if the Variant is not a string type.

Do no remove, this fixes the anchor on doc.flexsim.com

Variant.toNum()

double toNum( )

Returns

double The interpreted content of the string as a double.

Description

Interprets a string Variant's content as a floating point number.

Forwards to string.toNum. An exception is thrown if the Variant is not a string type.
Do no remove, this fixes the anchor on doc.flexsim.com

Variant.toUpperCase()

string toUpperCase( )

Description

Creates an upper case string from a string Variant.

Forwards to string.toUpperCase(). An exception is thrown if the Variant is not a string type.

Do no remove, this fixes the anchor on doc.flexsim.com

Variant.trim()

Variant trim( )

Description

Trims white space off of the ends of a string Variant.

Forwards to string.trim(). An exception is thrown if the Variant is not a string type.

Do no remove, this fixes the anchor on doc.flexsim.com

Variant.unshift()

Variant unshift( Variant value )

Returns

Variant The modified Variant.

Description

Unshifts (pushes) a value onto the front of an Array Variant.

Forwards to Array.unshift(). If the Variant is a non-array value, it will convert itself into an Array, and forward to Array.unshift(). If it is a null Variant, it will become the passed value (not an Array).

Do no remove, this fixes the anchor on doc.flexsim.com

Variant.operator -

double operator -( double value )
double operator -( Variant value )

Parameters

value The value to subtract from the Variant

Returns

double The result of the subtraction.

Description

Subtracts two numbers.

The following example uses treenode.labelProperties to access an object's label value.

double myVal = current.labelValue - 2;
Do no remove, this fixes the anchor on doc.flexsim.com

Variant.operator --

double operator --( )

Description

Decrements a number Variant.

The following example uses treenode.labelProperties to decrement an object's label value.

current.labelValue--;
Do no remove, this fixes the anchor on doc.flexsim.com

Variant.operator !

int operator !( )

Returns

int True if the Variant is a null Variant, a NULL treenode, or the number 0.0. False otherwise.

Description

Tests if a Variant is either a null Variant, a NULL treenode, or a 0.0 number.

The following example uses treenode.labelProperties to compare an object's label value.

if (!current.labelValue) {
	...
}
Do no remove, this fixes the anchor on doc.flexsim.com

Variant.operator !=

int operator !=( int value )
int operator !=( double value )
int operator !=( string value )
int operator !=( treenode value )
int operator !=( Variant value )

Parameters

value The value to compare against.

Returns

int True if the Variant is not equal to value, false otherwise.

Description

Tests if a Variant is not equal to another value.

The following example uses treenode.labelProperties to compare an object's label value.

if (current.labelValue != 5) {
	...
}
Do no remove, this fixes the anchor on doc.flexsim.com

Variant.operator %

int operator %( int value )
int operator %( Variant value )

Parameters

value The value used as the modulus.

Returns

int The modulus of the Variant and the other value.

Description

Returns the modulus of two numbers.

The modulus operator returns the remainder of a division.
Do no remove, this fixes the anchor on doc.flexsim.com

Variant.operator *

double operator *( double value )
double operator *( Variant value )

Parameters

value The value to multiply by.

Returns

double The multiplication product of the two values.

Description

Multiplies two numbers.

The following example uses treenode.labelProperties to access an object's label value.

double myVal = current.labelValue * 2;
Do no remove, this fixes the anchor on doc.flexsim.com

Variant.operator /

double operator /( double value )
double operator /( Variant value )

Parameters

value The value to divide the Variant by.

Returns

double The result of the division.

Description

Divides two numbers.

The following example uses treenode.labelProperties to access an object's label value.

double myVal = current.labelValue / 2;
Do no remove, this fixes the anchor on doc.flexsim.com

Variant.operator []

Variant operator []( int index )

Parameters

index The index of the array element.

Returns

Variant The array element at the specified index.

Description

Accesses an element of an Array Variant.

Forwards to the Array [] operator.

The Variant implements special logic associated with arrays in that you can treat a Variant like an Array even if it does not hold array data. If a Variant holds, for example, a string, you can treat the Variant as if it were a 1-length Array with a string as its first element.

Variant val = "Hello";
int len = val.length; // len = 1
return val[len]; // returns "Hello";
Do no remove, this fixes the anchor on doc.flexsim.com

Variant.operator +

double operator +( double value )
Variant operator +( Variant value )

Parameters

value The value to add to the Variant.

Returns

double The addition result.

Description

Adds two numbers.

The following example uses treenode.labelProperties to access an object's label value.

double myVal = current.labelValue + 2;
Do no remove, this fixes the anchor on doc.flexsim.com

Variant.operator ++

double operator ++( )

Description

Increments a number Variant

The following example uses treenode.labelProperties to increment an object's label value.

current.labelValue++;
Do no remove, this fixes the anchor on doc.flexsim.com

Variant.operator +=

Variant operator +=( double value )
Variant operator +=( string value )

Parameters

value The value to add to the Variant.

Description

Increments a number Variant by a defined value, or appends a string to the current string Variant.

If both operands are strings, then the Variant will append value to itself. If both are numbers, the Variant will increment its value by value.

The following example uses treenode.labelProperties to access an object's label value.

double myVal = current.labelValue - 2;
Do no remove, this fixes the anchor on doc.flexsim.com

Variant.operator <

int operator <( int value )
int operator <( double value )
int operator <( Variant value )

Parameters

value

Returns

int

Description

Tests if a Variant is less than a number.

The following example uses treenode.labelProperties to compare an object's label value.

if (current.labelValue < 5) {
	...
}
Do no remove, this fixes the anchor on doc.flexsim.com

Variant.operator <=

int operator <=( int value )
int operator <=( double value )
int operator <=( Variant value )

Parameters

value

Returns

int

Description

Tests if a Variant is less than or equal to a number.

The following example uses treenode.labelProperties to compare an object's label value.

if (current.labelValue <= 5) {
	...
}
Do no remove, this fixes the anchor on doc.flexsim.com

Variant.operator -=

Variant operator -=( double value )

Parameters

value The value to decrement the Variant by.

Description

Decrements a number Variant by a defined value.

The following example uses treenode.labelProperties to decrement an object's label value.

current.labelValue -= 2;
Do no remove, this fixes the anchor on doc.flexsim.com

Variant.operator ==

int operator ==( int value )
int operator ==( double value )
int operator ==( string value )
int operator ==( treenode value )
int operator ==( Variant value )

Parameters

value The value to compare against.

Returns

int True if the Variant is equal to value, false otherwise.

Description

Tests if two values are equal to each other.

The following example uses treenode.labelProperties to compare an object's label value.

if (current.labelValue == 5) {
	...
}
Do no remove, this fixes the anchor on doc.flexsim.com

Variant.operator >

int operator >( int value )
int operator >( double value )
int operator >( Variant value )

Parameters

value The value to compare against.

Returns

int True if the Variant is greater than value, false otherwise.

Description

Tests if a Variant is greater than a number.

The following example uses treenode.labelProperties to compare an object's label value.

if (current.labelValue > 5) {
	...
}
Do no remove, this fixes the anchor on doc.flexsim.com

Variant.operator >=

int operator >=( int value )
int operator >=( double value )
int operator >=( Variant value )

Parameters

value The value to compare against.

Returns

int True if the Variant is greater than or equal to value, false otherwise.

Description

Tests if a Variant is greater than or equal to a number.

The following example uses treenode.labelProperties to compare an object's label value.

if (current.labelValue >= 5) {
	...
}