{$expression}
Question Text |
Result & Comments |
---|---|
The value is {$3} meters. |
"The value is 3 meters." - not particularly useful, but it works... |
The value is {$M} meters. |
Replaces "{$M} with the numeric value of the variable "M". If M has the value 3, for instance, the result is "The value is 3 meters." If M = 5, the result is "The value is 5 meters." |
The value is {$3*M} meters. |
If M = 3, the result will be "The value is 9 meters.". If M = 5, the result will be "The value is 15 meters." |
The value is {$3*M/X + 1} meters. |
The string "{$3*M/X + 1} will be replaced with its value. For instance, if M = 6 and X = 2, the result will be "The value is 10 meters.". |
A numeric substitution of the form {$expression} will substitute the integer value of "expression" into the surrounding text. In other words, if the value of P is 3.14159, the substitution "¹ is about {$P}." will result in "¹ is about 3.".
To control the number of decimal places actually substituted, use the following:
{$expression:format}
where the colon (":") separates the "expression" whose value is to be substituted, from "format" which is an expression which evaluates to an integer. The value of "format" indicates the number of decimal places to use when displaying "expression".
If "format" evaluates to a positive value, it indicates the number of decimal places to the right of the decimal point to include in the substituted value. If "format" evaluates to a negative value, it indicates the number of decimal places to the left of the decimal point to round the value of "expression" before substitution. For example:
Question Text |
Result & Comments |
---|---|
The value is {$P:2} |
If P = 3.14159, the result is "The value is 3.14." |
The value is {$P:2*X} |
If P = 3.14159 and X=2, the result is "The value is 3.1416". |
The value is {$P:X} |
If P = 123456 and X=-2, the result is "The value is 123400. |