Mathematical
Purpose: |
Perform a mathematical calculation. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Category: |
Mathematical |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Syntax: |
Math "formula" decimalPlaces [variable] formula A mathematical formula. The formula can include operators and functions like +, -, *, / (see the complete list of supported symbols below). Parentheses and variables may also be used in formulas. decimalPlaces The number of decimal places to include in the result. Use 0 (zero) to round the result to the nearest whole number or -1 to have VisualNEO Web automatically determine the optimal number of decimal places variable The name of the variable to store the result. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Example: |
In the example below, a variable [MonthlyRent] is used to calculate the amount of rent paid per week. [monthlyRent] could be set using the SetVar Action, or associated with a Text Entry object to allow the user to enter a number. The result is stored in the variable [weeklyRent]. SetVar [monthlyRent] 1200 Math "([monthlyRent]*12)/52" 2 [weeklyRent] |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Supported symbols: |
|
Remark 1
Math action accept complex formulas as its first parameter:
Example: Math "pow(9, 1/2)" 0 [number]
-> expected value: 3
Remark 2
Javascript has a lot of built-in mathematical functions that can be used. See Section Advanced for
information about the communication between NeoScript and Javascript.
Example: |
BeginJS alert("Minimum: " + Math.min(-2, -3, -1)); //-> -3 EndJS |
Purpose: |
Generate a random number between 0 (inclusive) and a maximum value (inclusive). |
Category: |
Mathematical |
Syntax: |
Random maxVal [variable] maxVal The maximum possible value for the generated number. The number returned will be somewhere between 0 (zero) and maximum value (inclusive). variable The name of the variable to store the random number. |
Example: |
Random 3 [number] -> expected value: 0, 1, 2 or 3 |
Purpose: |
Generate a random number between a minimum (inclusive) and a maximum value (inclusive). |
Category: |
Mathematical |
Syntax: |
Random minVal maxVal [variable] minVal The minimum possible value for the generated number. maxVal The maximum possible value for the generated number. variable The name of the variable to store the random number. |
Example: |
RandomEx 1 3 [number] |
Purpose: |
Convert a string variable to a number. |
Category: |
Mathematical |
Syntax: |
ToNumber [string var] [result var] [string var] Variable with text content. [result var] Variable to store the numeric result |
Example: |
SetVar [myvar] "3 monkeys" |