Various mathematical routines can be incorporated into CSTalk macro scripts to help perform certain user functions.
Simple Mathematical Operators
Simple mathematical operators include the multiplication (*), division (/), addition (+) and subtraction (-) functions. These can be implemented within parameters of virtually any procedure or logical operator that is expecting a numerical input. An example are shown below.
EXAMPLE
GetArrayLength(&Array_Length,&DynamicArray)
AssignVariable(&DynamicArray[&Array_Length+1],4+6-3)
This example reads the length of a previously declared user array variable. The array is then extended by one position (by assigning to its length + 1) and a value of 7 (4+6-3) is then assigned to the last array position.
LogE (Result Variable , Value )
LogE returns the log base e of Value.
Log10 (Result Variable , Value )
Log10 returns the log base 10 of Value.
Exp (Result Variable , Value )
Exp returns the value of e raised to the power of Value, where e is the base of the natural logarithms.
Round (Result Variable , Value, Method )
Round returns the rounded version of Value in accordance with the following rounding methods:
UP - Rounds Up
DOWN - Rounds Down
NEAREST - Rounds to closest value (.5 rounded up)
TRUNCATE - Truncates the value, rounding positive numbers down and negative numbers up.