SORTCLPVAR SORT CLP VARIABLE TAACLTH |
The Sort CLP Variable command provides a sort of a number of fixed
length elements of up to 100 bytes in a 32,000 byte variable. The
data is sequenced in either ascending or descending order and
returned in the same variable. The array may be loaded by a tool
such as LOOKUP2. The first all blank element or if the variable is
full signals the end of the elements.
A typical series of commands would be:
DCL &VAR *CHAR LEN(32000)
DCL &ELEMENT *CHAR LEN(nn)
DCL &NXT *DEC LEN(5 0)
.
/* Load the array such as with LOOKUP2 */
.
/* Sort */
SORTCLPVAR VAR(&VAR) ELMLEN(nn)
.
/* Process */
.
CHGVAR &NXT (1 - nn)
LOOP: CHGVAR &NXT (&NXT + nn)
CHGVAR &ELEMENT %SST(&VAR &NXT nn)
IF (&ELEMENT *EQ ' ') DO /* End of entries */
GOTO xxx
ENDDO /* End of entries */
.
/* Process the entry */
.
GOTO LOOP
In this example, a blank entry determines the end of the loop. The
number of entries (optional return variable on SORTCLPVAR) may also
be used to determine the end of the loop.
SORTCLPVAR escape messages you can monitor for
----------------------------------------------
None. Escape messages from based on functions will be re-sent.
SORTCLPVAR Command parameters *CMD
-----------------------------
VAR The variable containing the elements to be
sequenced. It must be declared as *CHAR LEN(32000).
The value is input to the command and the data is
sequenced and returned in the same variable. The
first blank element or if the variable is full
signals the end of the elements.
The element length does not have to divide evenly
into 32,000.
ELMLEN The length of the elements in the VAR array. A
value between 1 and 100 must be specified.
SEQ How to sequence the data. *ASCEND for ascending
sequence is the default.
*DESCEND may be specified to sequence in descending
order.
NBRENT The number of elements found in the array. This is
an optional return variable that if used must be
specified as *DEC LEN(5 0)
Restrictions
------------
Because SORTCLPVAR returns a variable, the command may only be used
in a CL program.
Prerequisites
-------------
The following TAA Tools must be on your system:
SNDESCINF Send escape information
SNDESCMSG Send escape message
Implementation
--------------
None, the tool is ready to use.
Objects used by the tool
------------------------
Object Type Attribute Src member Src file
------ ---- --------- ---------- ----------
SORTCLPVAR *CMD TAACLTH QATTCMD
TAACLTHC *PGM CLP TAACLTHC QATTCL
TAACLTHR *PGM RPGLE TAACLTHR QATTRPG
|
Added to TAA Productivity tools January 15, 2009