The Retrieve Data Length (RTVDTALXCL) command retrieves the length of a character string value. The length can be determined either by trimming trailing blanks or by the presence of a null character. The character data can be encoded in EBCDIC, ASCII, or Unicode.
This function is also available with command RTVDTALEN in library VC2XCL. Any use of this alternative command name should be library qualified in case the i operating system were to use this command name in a future release.
Length (LEN)
Specifies the CL variable which will be used to return the length of the character string found in the variable identified by the VAR parameter. The returned length is in bytes.
This is a required parameter.
- integer
- Specify the name of the CL variable.
Examples for RTVDTALXCL
Example 1: Ignoring Trailing Blanks Using Job CCSID
Dcl Var(&Char) Type(*Char) Len(10) +
Value('123456 ')
Dcl Var(&Length) Type(*Int)
RtvDtaLXCL Var(&Char) Len(&Length)
This example returns the length of the character string found in variable &Char ignoring trailing blanks. After the RTVDTALXCL command has run the value of CL variable &Length will be 6.
Example 2: Ignoring Trailing Blanks Using Unicode
Dcl Var(&UCS) Type(*Char) Len(16) +
Value(x'00610062006300640065006600200020')
Dcl Var(&Length) Type(*Int)
RtvDtaLXCL Var(&UCS) Len(&Length) CCSID(*UCS2)
This example returns the length of the Unicode character string found in variable &UCS ignoring trailing blanks. In display form the value of &UCS is '123456 '. After the RTVDTALXCL command has run the value of CL variable &Length will be 12 reflecting that the string is 12 bytes in length. Note that this represents 6 Unicode characters.
Example 3: Determining Length Using a Null Character
Dcl Var(&Char) Type(*Char) Len(10) +
Value(x'C1C2C300C5C640404040')
Dcl Var(&Length) Type(*Int)
RtvDtaLXCL Var(&Char) Len(&Length) LenDLM(*Null)
This example returns the length of the character string found in variable &Char that is delimited by a null character. After the RTVDTALXCL command has run the value of CL variable &Length will be 3. The EBCDIC null character (x'00') is found in the fourth byte of CL variable &Char and the returned length does not include the null character.