%TRIM(string {: characters to trim})
1 つのパラメーターのみが指定された %TRIM は、すべての先行および後書きブランクを除去したうえで、 指定されたストリングを戻します。
2 つのパラメーターが指定された %TRIM は、トリミング対象文字パラメーター で 先行および末尾の文字を除去したうえで、指定されたストリングを戻します。
このストリングは、文字、図形、また は UCS-2 のどのデータでもかまいません。
トリミング対象文字 パラメーターを指定する場合には、 ストリング・パラメーターと同じタイプを指定する必要があります。
詳細については、ストリング命令または 組み込み関数を参照してください。
*..1....+....2....+....3....+....4....+....5....+....6....+....7...+....
D*Name++++++++++ETDsFrom+++To/L+++IDc.Keywords+++++++++++++++++++++++++
D Location S 16A
D FirstName S 10A inz (' Chris ')
D LastName S 10A inz (' Smith ')
D Name S 20A
* LOCATION will have the value 'Toronto, Ontario'.
/FREE
Location = %trim (' Toronto, Ontario ');
// Name will have the value 'Chris Smith! '.
Name = %trim (FirstName) + ' ' + %trim (LastName) + '!';
/END-FREE
D edited S 20A INZ('$******5.27*** ')
D trimmed S 20A varying
D numeric S 15P 3
/FREE
// Trim '$' and '*' from the edited numeric value
// Note: blanks will not be trimmed, since a blank
// is not specified in the 'characters to trim' parameter
trimmed = %trim(edited : '$*'); // trimmed is now '5.27*** '
// Trim '$' and '*' and blank from the edited numeric value
trimmed = %trim(edited : '$* '); // trimmed is now '5.27'
// Get the numeric value from the edited value
numeric = %dec(%trim(edited : '$* ') : 31 : 9); // numeric is now 5.27