ED
Formats an integer using a pattern.
Type
String function
Format
ED(number 'pattern') - number
- The value to be formatted.
- pattern
- A string of 1 to 40 characters that control how number is
formatted. Valid control characters are:
- #
- Digit selector. If the corresponding digit in number is non-zero, it is placed in the result string.
- /
- Significance starter and digit selector. The current digit in number is processed for #, and the significance flag is turned on. Leading zeros are forced from this point.
Usage Notes®
- ED returns a null string if an error was detected. An error can be caused by a pattern that is null or longer than 40 characters, a pattern that has more than 15 digit selectors and significance starters, or a non-numeric number.
- ED returns a non-null string when the number formats as requested.
- The first character in pattern should not be # or /. Incorrect output can result.
- If number has more digits than pattern has digit selectors or significance starters, the left-most digits are truncated.
Example
Assuming that the variable A contains a value that has 2
implicit decimal positions, the following example formats it with
U.S. numeric punctuation (commas between groups of 3 digits and a
period at the decimal point). Blank spaces are indicated by ƀ
set Temp (ed(&A 'ƀ##,###,###.##'))If A contains the value 123456789, the ED function returns
the string with commas, a decimal point, and leading blanks:
ƀƀ1,234,567.89To remove the leading blanks, use the TRIM function:
set Result (trim(&Temp))The following table shows the different pattern actions.
| Pattern | -2345 | 2345 |
|---|---|---|
| 'ƀ####' | 'ƀ2345' | 'ƀ2345' |
| 'ƀ2345' | 'ƀ2345-' | 'ƀ2345ƀ' |
| 'ƀ####cr' | 'ƀ2345cr' | 'ƀ2345ƀƀ' |
| 'ƀ####neg' | 'ƀ2345neg' | 'ƀ2345ƀƀg' |
| 'ƀ####negƀ' | 'ƀ2345negƀ' | 'ƀ2345ƀƀƀƀ' |
| 'ƀ#-#-#-#-#' | 'ƀƀƀ2-3-4-5' | 'ƀƀƀ2-3-4-5' |