Where allowed to run:
|
Parameters Examples Error messages |
The Scan a CL Variable (CLSCAN) command scans a CL variable for the specified pattern and returns its location to another CL variable.
Restrictions:
Top |
Keyword | Description | Choices | Notes |
---|---|---|---|
PATTERN | Search for pattern | Character value | Required, Positional 1 |
SCHDATA | Data or CL variable to search | Character value | Required, Positional 2 |
CASE | Match upper/lower case | *MATCH, *IGNORE, *YES, *NO | Optional, Positional 3 |
START | Start searching in position | Integer, 1 | Optional, Positional 4 |
LEN | Max chars to search from Start | Integer, *END | Optional, Positional 5 |
RTNPOS | CL-var to receive position | Not restricted | Optional, Positional 6 |
RTNCHAR | Char CL-var for position | Character value | Optional, Positional 7 |
Top |
Specify what is to be searched for. The "pattern".
This is a required parameter.
Top |
Specify the string or CL variable to be searched for the pattern. This parameter has a maximum length of 5000 characters.
This is a required parameter.
Top |
Specifies whether a case-sensitive scan is performed.
Top |
Specify the starting position where the scan is to begin. This value identifies the first character of the searched data that is scanned for the pattern.
Top |
Specify the number of characters of the searched data value to be scanned, starting from the START value.
Top |
Specify a CL variable to receive the scan position if the scan pattern is located in the searched data.
Top |
Specify an optional CL variable of TYPE(*CHAR) that receives the found position as left-justified text. This is provided to avoid that additional step often necessary with numeric to character CL conversions.
Top |
Example 1:Case Insensitive CLSCAN
DCL &POS TYPE(*DEC) LEN(7 0) CLSCAN PATTERN('company') SCHDATA(&COMPNAME) CASE(*IGNORE) RTNPOS(&POS)
This command performs a case insensitive scan of the &COMPNAME CL variable for the word 'company' and if found, returns the location to the &POS CL variable.
Example 2: More Complex CLSCAN Example
DCL &POS TYPE(*DEC) LEN(7 0) DCL &POSA TYPE(*CHAR) LEN(5) CLSCAN PATTERN('company') SCHDATA(&COMPNAME) START(5) LEN(16) RTNPOS(&POS) RTNCHAR(&POSA)
This command performs a case-sensitive scan beginning in position 5 of &COMPNAME through position 20 (Pos 5 + Len(16) = Pos 5 to 20) and if found, returns the position as numeric to the &POS variable and as left-justified text to the &POSA variable.
Top |
Top |