Expressions


Functions

The following function requires no arguments and can be used in an expression.

timeNow()

returns the current simulation clock value.

The following arithmetic functions can be used in an expression.

abs(arg1)

returns the absolute value of a single numeric argument.

floor(arg1)

returns the largest integer that is less than or equal to a single numeric argument.

ceil(arg1)

returns the smallest integer that is greater than or equal to a single numeric argument.

round(arg1,arg2)

returns the numeric argument arg1 rounded off to the specified precision arg2, where arg2 > 0 rounds off arg1 up to arg2 decimal places to the left of the decimal point, arg2 < 0 rounds off arg1 up to arg2 decimal places to the right of the decimal point, and arg2=0 rounds off arg1 to the closest integer. The default value for arg2 is 0. The rounding function returns 0 for any invalid value of arg2 (where valid values of arg2 depend on the value of arg1).

min(arg1,arg2,...)

returns the minimum value among two or more numeric arguments.

max(arg1,arg2,...)

returns the maximum value among two or more numeric arguments.

power(arg1,arg2)

returns the first numeric argument arg1 raised to the power of the second numeric argument arg2.

sin(arg1)

returns the trigonometric sine of a single numeric radians argument.

cos(arg1)

returns the trigonometric cosine of a single numeric radians argument.

tan(arg1)

returns the trigonometric tangent of a single numeric radians argument.

asin(arg1)

returns the trigonometric arc sine of a single numeric radians argument.

acos(arg1)

returns the trigonometric arc cosine of a single numeric radians argument.

atan(arg1)

returns the trigonometric arc tangent of a single numeric radians argument.

sinh(arg1)

returns the trigonometric hyperbolic sine of a single numeric radians argument.

cosh(arg1)

returns the trigonometric hyperbolic cosine of a single numeric radians argument.

tanh(arg1)

returns the trigonometric hyperbolic tangent of a single numeric radians argument.

log(arg1)

returns the base 10 logarithm of a single numeric argument.

ln(arg1)

returns the natural logarithm of a single numeric argument.

exp(arg1)

returns e (Euler’s number) raised to the power of a single numeric argument.

The following string functions can be used in an expression.

concat(arg1,arg2,...)

returns the concatenation of two or more string arguments.

substring(string,index,length)

returns the substring of string starting at the specified zero-based index. For length > 0, the substring starting at index is returned; for length < 0, the substring ending at index is returned; if length is not specified, the substring from index to the end of string is returned.

The following conversion functions can be used in an expression.

degrees(arg1)

returns the degrees equivalent of a single numeric radians argument.

radians(arg1)

returns the radians equivalent of a single numeric degrees argument.

toString(arg1)

returns a string representation of a single argument.

toNumber(arg1)

returns a numeric representation of a single argument (if possible).

toBoolean(arg1)

returns the Boolean value false for a numeric argument with value 0 or a string argument with value other than "true". Returns the Boolean value true for a nonzero numeric argument or a string argument with value "true".

The following argument-index functions can be used in an expression.

minindex(arg1,arg2,...)

returns the zero-based index of the argument with the smallest value among two or more numeric arguments.

maxindex(arg1,arg2,...)

returns the zero-based index of the argument with the largest value among two or more numeric arguments.

The following logical functions can be used in an expression.

cond

has the following syntax: cond(Boolean expression, true return value, false return value). The value returned by this function is determined by evaluating the Boolean expression that is the first argument. If the Boolean expression evaluates to true, the second argument is returned. Otherwise, the third argument is returned.

switch

has the following syntax: switch(Boolean expression 1, value 1, Boolean expression 2, value 2, ..., default value). The value returned by this function is the value argument immediately following the first Boolean expression argument that evaluates to true. The default value is returned if none of the Boolean expression arguments evaluate to true.