- (*, precedence) This example prints 15 for the first @Prompt because
the multiplication 4 * 3 is evaluated first. It prints 21 for the
second @Prompt because the parentheses force the evaluation of 3 +
4 first.
@Prompt([Ok]; "3 + 4 * 3"; @Text(3 + 4 * 3)); @Prompt([Ok]; "(3 + 4) * 3"; @Text((3 + 4) * 3))
- (/ *) This example prints 0.333333333333333 for the first @Prompt,
performing the division and rounding the result to 15 decimal places.
It prints 1.2635268885E+17 for the second @Prompt, presenting the
11 most significant digits of the result as a fraction multiplied
by 1017.
@Prompt([Ok]; "1 / 3"; @Text(1 / 3)); @Prompt([Ok]; "123456789 * 1023456789"; @Text(123456789 * 1023456789))
- (@Abs) This example calculates the difference between Score1 and
Score2 as an unsigned number, no matter which is larger.
@Abs(Score1 - Score2)
- (@Abs) This example calculates the absolute difference between
Sales and CostOfSales, and formats it in a text field placing parentheses
around a negative result.
GP := @Abs(Sales - CostOfSales); @If(Sales >= CostOfSales; @Text(GP); "(" + @Text(GP) + ")")
- (@Sign) This agent example displays the Total field. If the field
value is negative, its absolute value is placed in parentheses; if
the field value is zero, the word "Zero" is displayed.
sign := @Sign(Total);
display := @If(sign = 1; @Text(Total); sign = -1; "(" + @Text(@Abs(Total)) + ")"; "Zero");
@Prompt([Ok]; "Total"; display);
SELECT @All
- (@Sum) This example prints 15, the sum of the list One23, the
variable Four, and the constant 5.
One23 := 1 : 2 : 3; Four := 4;
S := @Sum(One23; Four; 5); @Prompt([Ok]; "Sum of 1-5"; @Text(S))
- (@Integer) This example truncates 3.12 to 3 and 6.735 to 6.
@Prompt([Ok]; "@Integer(3.12)"; @Text(@Integer(3.12))); @Prompt([Ok]; "@Integer(6.735)"; @Text(@Integer(6.735)))
- (@Integer) This example truncates Sales and Commission to integers
in a list.
@Integer(Sales : Commission)
- (@Round) This example rounds 3.12 to 3, 6.735 to 7, and 7.5 to
8; 753 by tens to 750; and the list elements 3.12, 6.735, and 7.5
to 3, 6, and 7 respectively (converting them to a text string for
display).
@Prompt([Ok]; "@Round(3.12)"; @Text(@Round(3.12))); @Prompt([Ok]; "@Round(6.735)"; @Text(@Round(6.735))); @Prompt([Ok]; "@Round(7.5)"; @Text(@Round(7.5))); @Prompt([Ok]; "@Round(753; 10)"; @Text(@Round(753; 10))); @Prompt([Ok]; "@Round(3.12 : 6.735 : 7.5)"; @Implode(@Text(@Round(3.12 : 6.735 : 7.5))))
- (@Max) This example prints 99, the maximum of 99, 2, and 3; 3,
the maximum of 1 and 3; and 99 6 7 8, the maximum of the pair-wise
elements in the two lists.
@Prompt([Ok]; "@Max(99 : 2 : 3)"; @Text(@Max(99 : 2 : 3))); @Prompt([Ok]; "@Max(1; 3)"; @Text(@Max(1; 3))); @Prompt([Ok]; "@Max(99 : 2 : 3; 5 : 6 : 7 : 8)"; @Implode(@Text(@Max(99 : 2 : 3; 5 : 6 : 7 : 8))))
- (@Min) This example prints 2, the minimum of 99, 2, and 3; 1,
the minimum of 1 and 3; and 5 2 3 3, the minimum of the pairwise elements
in the two lists.
@Prompt([Ok]; "@Min(99 : 2 : 3)"; @Text(@Min(99 : 2 : 3))); @Prompt([Ok]; "@Min(1; 3)"; @Text(@Min(1; 3))); @Prompt([Ok]; "@Min(99 : 2 : 3; 5 : 6 : 7 : 8)"; @Implode(@Text(@Min(99 : 2 : 3; 5 : 6 : 7 : 8))))
- (@Modulo) This example prints 1, the remainder of 4/3; -2, the
remainder of -14/3 (the remainder is negative when the dividend is
negative); and 1 2 3 3, the remainders of the pairwise division of
the first list by the second in the third line.
@Prompt([Ok]; "@Modulo(4; 3)"; @Text(@Modulo(4; 3))); @Prompt([Ok]; "@Modulo(-14; 3)"; @Text(@Modulo(-14; 3))); @Prompt([Ok]; "@Modulo(4 : 6 : 8 : 9; 3 : 4 : 5 : 6)"; @Implode(@Text(@Modulo(4 : 6 : 8 : 9; 3 : 4 : 5 : 6))))
- (@Modulo) This example determines if the input number is even
(division by 2 leaves a remainder of 0) or odd.
n := @TextToNumber(@Prompt([OkCancelEdit]; "Input Number"; "Type a number"; "")); @Prompt([Ok]; "The number is ..."; @If(@Modulo(n; 2) = 0; "Even"; "Odd"))
- This example compares the fields SpecifiedLength and MeasuredLength,
and displays a message if the fields are not within 0.01.
@If(@FloatEq(SpecifiedLength; MeasuredLength; 0.01); "";
@Prompt([Ok]; "Length is out of spec";
@Text(MeasuredLength)))
- (@Power) This example prints 8, 2 raised to the power of 3; -8,
-2 raised to the power of 3; and 0.125, 2 raised to the power of -3.
@Prompt([Ok]; "@Power(2; 3)"; @Text(@Power(2; 3))); @Prompt([Ok]; "@Power(-2; 3)"; @Text(@Power(-2; 3))); @Prompt([Ok]; "@Power(2; -3)"; @Text(@Power(2; -3)))
- (@Sqrt, @Power) This example, which is the value formula for a
computed field, calculates the diagonal of a rectangle using the values
specified in the Length and Width fields.
@If(Length = "" | Width = ""; ""; @Sqrt(@Power(Length; 2) + @Power(Width; 2)))
- (@Pi, @Power) This example, which is the value formula for a computed
field, calculates the area of a circle using the values specified
in the Radius field.
@If(Radius = ""; ""; @Pi * @Power(Radius; 2))
- (@Log) This example prints 0.602059991327962, the common logarithm
of 4; and 14, the common logarithm of 1014.
@Prompt([Ok]; "Common log of 4"; @Text(@Log(4))); @Prompt([Ok]; "Common log of 1.0E+14"; @Text(@Log(1.0E+14)))
- (@Ln) This example prints 0.693147180559945, the natural logarithm
of 2.
@Prompt([Ok]; "Natural log of 2"; @Text(@Ln(2)))
- (@Exp) This example calculates 2.71828182845904 (the value of
e) for the first @Exp function, 3.49034295746184 (the value of e to
the 1.25) for the second @Exp function, and 0.28650479686019 (the
value of e to the -1.25) for the third @Exp function.
@Prompt([Ok]; "e to 1"; @Text(@Exp(1))); @Prompt([Ok]; "e to 1.25"; @Text(@Exp(1.25))); @Prompt([Ok]; "e to -1.25"; @Text(@Exp(-1.25)))
- (@Random) This view action example gets a number from a user and
compares it to a random number in the range 1 through 99, inclusive.
userNumber := @Prompt([OkCancelEdit]; "Number"; "Must be 1-99"; "");
winningNumber := @Text(@Integer(98 * @Random + 1));
@Prompt([Ok]; "Result"; @If(userNumber = winningNumber; "YOU WIN"; "Sorry - winning number is " + winningNumber))
- (@Sin, @Cos) This example shows the formulas for two computed
fields. The first formula calculates the length of a rectangle and
the second formula calculates its width.
Diagonal * @Sin(Angle * @Pi / 180)
Diagonal * @Cos(Angle * @Pi / 180)