%EDITC(numeric : editcode {: *ASTFILL | *CURSYM | currency-symbol})
%EDITC の結果は常に同じ長さで、先行ブランクと後書きブランクを含む場合が あります。 たとえば、%EDITC(NUM : 'A' : '$') は、NUM のある値の 場合には '$1,234.56CR' を戻し、別の値の場合 には ' $4.56 ' を戻します。
浮動式は、1 番目のパラメーターでは使用できません (%DEC を 使用して浮動形式を編集可能形式に変換することができます)。2 番目の パラメーターでは、編集コードは、文字定数として 指定されます。サポートされている編集コード は、'A' から 'D'、'J' から 'Q'、'X' から 'Z'、'1' から '9' です。定数 は、コンパイル時に値を決めることができるリテラル、名前付き定数、 あるいは式の場合があります。
詳細については、変換命令または 組み込み関数を参照してください。
DName+++++++++++ETDsFrom+++To/L+++IDc.Keywords+++++++++++++++++++++++++++
D msg S 100A
D salary S 9P 2 INZ(1000)
* If the value of salary is 1000, then the value of salary * 12
* is 12000.00. The edited version of salary * 12 using the A edit
* code with floating currency is ' $12,000.00 '.
* The value of msg is 'The annual salary is $12,000.00'
CL0N01Factor1+++++++Opcode&ExtExtended-factor2+++++++++++++++++++++++++++
C EVAL msg = 'The annual salary is '
C + %trim(%editc(salary * 12
C :'A': *CURSYM))
* In the next example, the value of msg is 'The annual salary is &12,000.00'
C EVAL msg = 'The annual salary is '
C + %trim(%editc(salary * 12
C :'A': '&'))
* In the next example, the value of msg is 'Salary is $*****12,000.00'
* Note that the '$' comes from the text, not from the edit code.
C EVAL msg = 'Salary is $'
C + %trim(%editc(salary * 12
C :'B': *ASTFILL))
* In the next example, the value of msg is 'The date is 1/14/1999'
C EVAL msg = 'The date is '
C + %trim(%editc(*date : 'Y'))
次の例では、サブプロシージャー内で %EDITC を使用してこれを実行します。
DName+++++++++++ETDsFrom+++To/L+++IDc.Keywords+++++++++++++++++++++++++++
D neg S 5P 2 inz(-12.3)
D pos S 5P 2 inz(54.32)
D editparens PR 50A
D val 30P 2 value
D editedVal S 10A
CL0N01Factor1+++++++Opcode&ExtExtended-factor2+++++++++++++++++++++++++++
C EVAL editedVal = editparens(neg)
* Now editedVal has the value '(12.30) '
C EVAL editedVal = editparens(pos)
* Now editedVal has the value ' 54.32 '
*---------------------------------------------------------------
* Subprocedure EDITPARENS
*---------------------------------------------------------------
P editparens B
D editparens PI 50A
D val 30P 2 value
D lparen S 1A inz(' ')
D rparen S 1A inz(' ')
D res S 50A
* Use parentheses if the value is negative
C IF val < 0
C EVAL lparen = '('
C EVAL rparen = ')'
C ENDIF
* Return the edited value
* Note that the '1' edit code does not include a sign so we
* don't have to calculate the absolute value.
C RETURN lparen +
C %editc(val : '1') +
C rparen
P editparens E