Where allowed to run:
|
Parameters Examples Error messages |
The CL Convert command converts between letter case or between CCSID (character sets). The converted value is copied to the designated CL variable.
Restrictions:
Top |
Keyword | Description | Choices | Notes |
---|---|---|---|
VAR | CL var for converted data | Not restricted | Required, Positional 1 |
VALUE | Data to convert | Character value | Required, Positional 2 |
XLATE | Type of Translation | *TOUPPER, *TOLOWER, *CCSID, *UPPER, *LOWER | Optional, Positional 3 |
FROMCCSID | Convert from CCSID | 0-65535, *JOB, *EBCDIC37, *ASCII, *UTF8 | Optional, Positional 4 |
TOCCSID | Convert to CCSID | 0-65535, *JOB, *EBCDIC37, *ASCII, *UTF8 | Optional, Positional 5 |
Top |
Specifies the TYPE(*CHAR) CL variable to receive the converted data. The CL variable may be up to 5000 bytes in length.
This is a required parameter.
Top |
Specifies the data to be converted. A literal, or a CL variable may be specified. When a CL variable is specified the length of the CL variable is used as the data length unless that CL variable is wrapped in the %TRIMR built-in function. Use caution when using %TRIMR on non-EBCDIC character strings as it may not produce the results you expect (that is, blanks in ASCII are X'20' not X'40')
This is a required parameter.
Top |
Top |
Specifies the CCSID of the data specified on the VALUE parameter. This parameter is used for all conversions.
Top |
Specifies the target CCSID identifier. This parameter is used only for CCSID conversions.
Top |
Example 1: Simple Command Example
DCL VAR(&ASCII) TYPE(*CHAR) LEN(50) DCL VAR(&MYNAME) TYPE(*CHAR) LEN(30) CHGVAR VAR(&MYNAME) VALUE('Bob Cozzi') CLCONVERT VAR(&ASCII) VALUE(&MYNAME) TOCCSID(*ASCII)
This command translates the content of the &MYNAME CL variable to PC ASCII (CCISD 819) and stores it in the &ASCII CL variable. The content of &MYNAME is expected to be in the CCSID of the job.
Example 2: More Complex Command Example
PGM PARM(&IFSDIR) DCL VAR(&IFSDIR) TYPE(*CHAR) LEN(640) DCL VAR(&FOLDER) TYPE(*CHAR) LEN(640) CLCONVERT VAR(&FOLDER) VALUE(%TRIMR( &IFSDIR X'20')) + FROMCCSID(*ASCII) TOCCSID(*JOB)
This command translates an IFS directory name from ASCII to the job CCSID so it can be used on subsequent IFS, PASE commands from within CL or passed to an RPG program. The IBM i v7R1 TR5 %TRIMR built-in function is used to trim off trailing ASCII spaces (i.e., blanks) from the &IFSDIR variable.
Top |
*ESCAPE Messages
Top |