The Lookup 3 command provides a simple lookup capability to check
whether an argument exists in an array. The array can be a large CL
variable of up to 5,000 bytes. If a blank value is found when
searching the array, the TAA9891 escape message is sent. A generic
search argument is supported.
A typical series of commands would be:
DCL &ARGUMENT *CHAR LEN(10)
DCL &ARRAY *CHAR LEN(1000)
.
LOOKUP3 ARGUMENT(&ARGUMENT) ARRAY(&ARRAY) +
ARGLEN(10)
MONMSG MSGID(TAA9891) EXEC(DO) /* Not found */
/* */
/* Your handling of 'not found' */
/* */
ENDDO /* Not found */
Each element is extracted from the array and compared to the
argument. If the argument does not match, the processing program
accesses the next element in the array. If the next element is
blank, the argument is considered not to be in the array and the
escape message is issued. If the array boundary will be exceeded,
the argument is determined to not be in the array and the escape
message is issued.
Generic values
--------------
The ARGUMENT parameter is not specified to allow for a generic name.
However, if the ARGUMENT ends with an *, the argument is considered
to be a generic value and the generic length will be used when
searching through the array. This approach allows normal generic
searching to be used. It also allows array values such as 123, 1234,
12345 to be found with an argument of 123*.
LOOKUP3 escape messages you can monitor for
-------------------------------------------
TAA9891 The argument does not exist.
Escape messages from based on functions will be re-sent.
LOOKUP3 Command parameters *CMD
--------------------------
ARGUMENT The argument to be searched for. It can be up to
100 bytes in length.
If the argument value ends with an *, the value is
considered to be generic and a generic search will
be made of the array element values.
If when searching the array, if a blank element is
found or the end of the array is reached, an escape
message is sent.
ARRAY The array to be searched. It can be up to 5,000
bytes in length.
ARGLEN The length of the argument to be searched. The
default is 10 bytes. The length must be between 1
and 100.
FOLD A *YES/*NO parameter for whether both the argument
and the array values should be folded to upper case.
*NO is the default to not fold.
*YES may be specified to fold both the argument and
the array values to upper case.
Restrictions
------------
None.
Prerequisites
-------------
The following TAA Tools must be on your system:
SCNVARRGT Scan variable right
SNDESCINF Send escape information
SNDESCMSG Send escape message
TRNVAL Translate value
Implementation
--------------
None, the tool is ready to use.
Objects used by the tool
------------------------
Object Type Attribute Src member Src file
------ ---- --------- ---------- ----------
LOOKUP3 *CMD TAACLTV QATTCMD
TAACLTVC *PGM CLP TAACLTVC QATTCL
|