Examples: Converting data types
- (@TextToNumber, @Text). This example reads a number interactively
using @Prompt, calculates its logarithm, and displays the answer interactively
using @Prompt. @Prompt works only with text values, so the input value
i must be converted to a number before its log can be calculated,
and the answer n must be converted to a text string before it can
be displayed.
i := @Prompt([OkCancelEdit]; "@Log Test"; "Enter a number"; ""); n := @Log(@TextToNumber(i)); @If(@IsError(n); @Return(@Prompt([Ok]; "@Log Test"; i + " is not a number")); ""); @Prompt([Ok]; "@Log Test"; "The logarithm of " + i + " is " + @Text(n))
- (@Text). This example converts the current date-time as returned
by @Now to text according to the date-time format T1S1 and displays
it. T1 means the time only, and S1 means the hour and minute only.
At six in the evening, the user sees an information box with "The
time is ..." as the header and "06:00 PM" as the contents.
@Prompt([Ok]; "The time is ..."; @Text(@Now; "T1S1"))
- (@Text). This example converts the number 800 to text according
to the number format C,2 and displays it. C means the currency format
(leading dollar sign) and 2 means two decimal places. The user sees
an information box with "800 dollars" as the header and "$800.00"
as the contents.
@Prompt([Ok]; "800 dollars"; @Text(800; "C,2"))
- (@Text, @TextToTime). This example converts the text string "Today"
to today's date, then converts it to a text string for @Prompt. For
example, if today is July 8, 1995, the user would see an information
box with "Today's Date" as the header and "07/08/95" as the contents.
@Prompt([Ok]; "Today's Date"; @Text(@TextToTime("Today")))
- (@IsNumber). This example adds Fields A and B. If either field
is not numeric, it is first converted to the numeric value 0. While
a user cannot enter a non-numeric value into a numeric field, a numeric
field that is left blank and has no default value formula defaults
to a null text string. The @IsNumber function in this formula traps
such an occurrence.
@If(@IsNumber(A); A; 0) + @If(@IsNumber(B); B; 0)
- (@Char). This example converts the integer 65 to an uppercase
A.
@Prompt([Ok]; "IBM Code Page 850 code 65"; @Char(65))