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.
If the digit is 0, the first character in pattern is placed in the result, unless either of 2 conditions is true:
  1. A previous non-zero digit was encountered.
  2. A significance starter control character was encountered.
/
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.
The first character in the string is copied to the output string and used as padding when a 0 digit is to be suppressed.
When the last digit in number is processed, the significance indicator is turned off, unless the number is negative, in which case it is turned on. Trailing characters are replaced with the pad character when the number is positive, and copied without change when the number is negative.
The last character in pattern is copied to the result unless it is a minus sign or the last 2 characters are CR. These characters are suppressed unless the number is negative.
All other characters are placed without change in the result string if the significance indicator is on. Otherwise, they are replaced with the pad character.

Usage Notes®

  1. 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.
  2. ED returns a non-null string when the number formats as requested.
  3. The first character in pattern should not be # or /. Incorrect output can result.
  4. 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.89
To 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'