Contents
Type Conversion
The eServices Field Codes use the following type conversions:
Bool
Description
Returns a Boolean converted from a number or a string.
Syntax
Bool(Arg, [Default
])
Argument |
Description |
Arg |
If a number, then converts 0 to False and nonzero to True.
|
Remarks
Example |
Result |
<$Bool(0)$> |
False
|
<$Bool(25.23)$> |
True
|
<$Bool("Yes")$> |
True
|
<$Bool("off", True)$> |
False
|
<$Bool("Asteroids")$> |
False
|
<$Bool("Asteroids", True)$> |
True
|
Num
Description
Returns a number converted from a string.
Syntax
Num (String[, String]
)
Argument |
Description |
First argument |
The string to be converted. May be expressed in scientific notation. Returns 0 if the string is not recognizable as a number. Ignores nonnumeric characters following the number. |
Second argument |
Optional. The locale that must be used to parse the first argument. Some examples include: en_US for English (United States), en_GB for English (United Kingdom), and fr_FR for French (France). See the Values for fieldcode-format-locale Option in the eServices 8.1 Reference Manual for a complete list. |
Remarks
If the optional argument is omitted, first the E-mail Server fieldcode-format-locale option (see option description in the eServices 8.1 Reference Manual) in the email-processing section is used if present. Otherwise, the platform locale is used.
For clarity, the results shown in the Examples of Num String table appear with three digits after the decimal point and always in the en_US format. Default number formatting shows no digits after the decimal point. Use the Text function (see Field Codes in Standard Responses Reference: Text) or format operator (%) to override the default formatting.
Example |
Result |
---|---|
<$Num("10")$> |
10.000
|
<$Num("10.00")$> |
10.000 |
<$Num("10,00", "fr_FR")$> |
10.000
|
<$Num("12e-2")$> |
0.120
|
<$Num("12.2e2Zork")$> |
1220.000
|
<$Num("12,2e2Zork", "fr_FR")$> |
1220.000
|
<$Num("Zaxxon")$> |
0.000
|
Text
Text
Description
Returns a string converted from an argument of any data type. Use the format operator (:) as shorthand for this function.
Syntax
Text (Arg[, Pattern[, String]])
or
Arg:Pattern
Argument |
Description |
Arg |
The value to be converted |
Pattern |
Optional. The picture string to use for formatting. If omitted, default formatting is used. The syntax of the picture string depends on the data type. See Number Formatting - “Number Formatting (Arg is a Number)” ). |
String |
Optional. The locale that must be used to parse the first argument. Some examples include: en_US for English (United States), en_GB for English (United Kingdom), and fr_FR for French (France). See Values for the fieldcode-format-locale Option in the eServices 8.1 Reference Manual for a complete list. |
Number Formatting (Arg is a Number)
If Arg is a number, then the regular expression syntax of the optional pattern string is as follows:
-
#*.?#*
Where:
-
#
–The pound sign (#
) represents a digit. Any number of #
s, including 0 may appear before the decimal character. Specify the minimum number of digits that should appear to the left of the decimal. If the integer part of the formatted number contains fewer than the specified number of digits, the number is padded with leading zeros.
-
Any number of #
s, including 0, may appear after the decimal character. Specify the precision of the fractional part of the number. The number is rounded to the specified precision.
-
Only the decimal separator in the result is locale dependent (There is no grouping separator).
The Examples of Number Formatting table contains some examples.
Pattern |
Arg Value |
Locale |
Result |
---|---|---|---|
"" |
0 |
en_US
|
"0"
|
"" |
123.456 |
en_US
|
"123"
|
"#" |
0 |
en_US
|
"0"
|
"##" |
0 |
en_US
|
"00"
|
"##" |
123.456 |
en_US
|
"123"
|
"#." |
0 |
en_US
|
"0. "
|
"#." |
123.456 |
en_US
|
"123. "
|
".##" |
0 |
en_US
|
".00"
|
".##" |
0.456 |
en_US
|
".46"
|
".##" |
123.456 |
en_US
|
"123.46"
|
".##" |
20000.456 |
en_US
|
"20000.46"
|
".##" |
123.456 |
fr_FR
|
"123,46"
|
".##" |
20000.456 |
fr_FR
|
"20000,46"
|
Duration Formatting (Arg is a Number)
If Arg is a number, then the regular expression syntax of the optional pattern string is as follows:
-
(<dur>).?#*
Where:
<dur> represents a duration and can be any of the sequences in the following list. (Upper- or lowercase letters are accepted.)
HH
HH:MM
HH:MM:SS
MM
MM:SS
SS
H
H:MM
H:MM:SS
M
M:SS
S
-
<dur> may be followed by a .## string, which specifies the precision of the last element of the duration. Any C or % suffixes are ignored. When you format a value as a duration, the value is always assumed to be expressed in days.
The pound sign (#) represents a digit. Any number of #
s, including 0, may appear before the decimal character and specify the minimum number of digits that should appear to the left of the decimal. If the integer part of the formatted number contains fewer than the specified number of digits, the number is padded with leading zeroes.
Any number of #
s, including 0, may appear after the decimal character and specify the precision of the fractional part of the number. The number is rounded to the specified precision.
The Examples of Duration Formatting table contains some examples.
Pattern |
Arg Value |
Locale |
Result |
---|---|---|---|
"HH" |
10.5083 |
en_US
|
"11"
|
"HH.## " |
10.5083 |
en_US
|
"10.51"
|
"HH:MM" |
10.5083 |
en_US
|
"10:30"
|
"HH:MM.# " |
10.5083 |
en_US
|
"10:30.5"
|
"HH:MM:SS" |
10.5083 |
en_US
|
"10:30:30"
|
"MM" |
10.5083 |
en_US
|
"630"
|
"MM.## " |
10.5083 |
en_US
|
"630.50"
|
"MM:SS" |
10.5083 |
en_US
|
"630:30"
|
"SS" |
10.5083 |
en_US
|
"37830"
|
Currency Formatting (Arg is a Number)
If Arg is a number, then the regular expression syntax of the optional parameter string is as follows:
-
#*.?#*[Cc]
Where:
A C or a c means format as currency. The grouping separator, the decimal separator, and the currency sign in the result are locale dependent.
The Examples of Currency Formatting table contains some examples
Pattern |
Arg Value |
Locale |
Result |
---|---|---|---|
"C" |
12.34 |
en_US
|
"$12.34"
|
"C" |
-12.34 |
en_US
|
"($12.34)"
|
"#.#C" |
12.34 |
en_US
|
"$12.3"
|
"#.#C" |
-12.34 |
en_US
|
"($12.3)"
|
"C" |
12.34 |
en_GB
|
"£12.34
" |
"C" |
-12.34 |
en_GB
|
"-£12.34
" |
"#.#C" |
12.34 |
en_GB
|
"£12.3
" |
"#.#C" |
-12.34 |
en_GB
|
"-£12.3
" |
".##C" |
20000.456 |
en_US
|
"$20,000.46"
|
".##C" |
20000.456 |
fr_FR
|
"20 000,46 €" |
Percentage Formatting (Arg is a Number)
If Arg is a number, then the regular expression syntax of the optional pattern string is as follows:
-
#*.?#*%
Where:
The percent sign (%
) means multiply by 100 and append the locale-dependent sign for percent values. If the % appears by itself, the formatter rounds to the nearest integral value and omits a decimal point (equivalent to the format #%
).
The grouping separator, the decimal separator, and the percent sign in the result are locale dependent.
The Examples of Percentage Formatting table contains some examples.
Pattern |
Arg Value |
Locale |
Result |
---|---|---|---|
"%" |
0 |
en_US
|
"0%"
|
"%" |
0.123456 |
en_US
|
"12%"
|
"#.##%" |
0.123456 |
en_US
|
"12.35%"
|
"#.##%" |
0.123456 |
fr_FR
|
"12,35%"
|
Date/Time Formatting
Use elements shown in the Date/Time Pattern Letters table to construct a Date/Time pattern string. The letters must be in uppercase or lowercase, as shown in the table (for example, MM not mm). Characters that are not picture elements, or that are enclosed in single quotation marks, will appear in the same location and unchanged in the output string.
Element |
Meaning |
---|---|
d |
Day of month as digits, with no leading zero for single-digit days |
dd |
Day of month as digits, with leading zero for single-digit days |
ddd |
Day of week as a three-letter abbreviation |
dddd |
Day of week as its full name |
M |
Month as digits, with no leading zero for single-digit months |
MM |
Month as digits, with leading zero for single-digit months |
MMM |
Month as a three-letter abbreviation |
MMMM |
Month as its full name |
y |
Year as last two digits, but with no leading zero for years less than 10 |
yy |
Year as last two digits, but with leading zero for years less than 10 |
yyyy |
Year represented by full four digits |
h |
Hours, with no leading zero for single-digit hours; 12-hour clock |
hh |
Hours, with leading zero for single-digit hours; 12-hour clock |
H |
Hours, with no leading zero for single-digit hours; 24-hour clock |
HH |
Hours, with leading zero for single-digit hours; 24-hour clock |
m |
Minutes, with no leading zero for single-digit minutes |
mm |
Minutes, with leading zero for single-digit minutes |
s |
Seconds, with no leading zero for single-digit seconds |
ss |
Seconds, with leading zero for single-digit seconds |
tt |
Time-marker string, such as AM or PM |
The examples in the Examples of Date/Time Formatting table assume that the date being formatted is August 6, 2003, @ 15:05:10:
Pattern |
Locale |
Result |
---|---|---|
"MMMM d, yyyy @ hh:mm:ss tt" |
en_US
|
"August 6, 2003 @ 03:05:10 PM"
|
"MMMM dd, yyyy @ HH:mm:ss" |
en_US
|
"August 06, 2003 @ 15:05:10"
|
"dd MMMM yyyy HH:mm:ss" |
fr_FR
|
"06 aout 2003 15:05:10"
|
"MMM d, yy @ h:mm:ss tt" |
en_US
|
"Aug 6, 03 @ 3:05:10 PM"
|
"M/dd/yy" |
en_US
|
"8/06/03"
|
Boolean Formatting
A Boolean picture string is simply two words separated by a comma. The first word is used if the Boolean value is True, and the second is used otherwise.
The Examples of Boolean Formatting table shows some examples:
Field Code |
Result |
<$Text(True, "Yup,Nope")$> |
"Yup"
|
<$Text(False, "Si,No")$> |
"No"
|
<$Text(False, "walnut,peach")$> |
"peach"
|
String Formatting
Picture strings do not apply to string values. Strings are always output unchanged. If you want to output a piece of a string, or change the case, then you can use one of the string-manipulation functions previously described.