Release the NEW Power of CL

Release the NEW Power of CL

Name:

Email:

Programming Services

Do you need a program written?

Bruce Vining Services can provide highly experienced IBM i developers to supplement your staff with short term contracts. We don't do general ledger but if you are looking for custom solutions involving system functions such as database, communications, security, encryption, print, and work management you will find your answers at Bruce Vining Services.

Retrieve Data Length PDF Print E-mail

Retrieve Data Length (RTVDTALXCL)

Where allowed to run:
  • Batch program (*BPGM)
  • Interactive program (*IPGM)
Threadsafe: Yes
Parameters
Examples
Error messages

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.

Top

Parameters

KeywordDescriptionChoicesNotes
VAR Character variable Character value Required, Positional 1
LEN Length Integer Required, Positional 2
LENDLM Length delimiter *BLANKS, *NULL Optional
CCSID CCSID of data Integer, *JOB, *ASCII, *UCS2, *UTF16, *UTF8 Optional
Top

Character variable (VAR)

Specifies the CL variable containing the character data.

This is a required parameter.

character-value
Specify the CL variable.
Top

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.
Top

Length delimiter (LENDLM)

Specifies the delimiter to use for determining the length of the character string.

*BLANKS
Trailing blanks will not be counted in the returned length.
*NULL
A null character will indicate the end of the character string. The null character will not be counted in the returned length.
Top

CCSID of data (CCSID)

Specifies the CCSID to be used when examining the CL variable identified by the VAR parameter. The CCSID identifies the encoding of blank and null characters.

*JOB
The CCSID of the job is used to determine the CCSID of the data to be examined. If the job CCSID is 65535, the default job CCSID will be used.
*ASCII
The data to be examined is in CCSID 819 (ISO Latin 1).
*UCS2
The data to be examined is in CCSID 13488 (Unicode UCS2).
*UTF16
The data to be examined is in CCSID 1200 (Unicode UTF16).
*UTF8
The data to be examined is in CCSID 1208 (Unicode UTF8).
integer
Specify a valid CCSID in the range of 1 to 65533.
Top

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.

Top

Error messages for RTVDTALXCL

*ESCAPE Messages

XCL500B
CCSID value of &1 is not supported.
XCL500C
Encoding scheme &1 not supported.
XCL500E
Character variable is not null terminated.
XCL9002
Function did not complete. See previously listed messages related to possible user errors.
XCL9003
Function did not complete. See previously listed messages for possible cause.
XCL9004
Function did not complete. See previously listed messages for possible cause.
XCL9005
Function did not complete. Contact your service provider.
Top
 
Joomla 1.5 Templates by Joomlashack