Please enable JavaScript to view this site.

This program will scan the String passed in PARM1 for the Pattern supplied in PARM2. If the pattern is found then a string will be returned based on the Offset and Return String length specified in parameters 5 & 6 respectively.

Parameter

In

Len

Out

Len

PARM1

String

132

Pattern start position #2

3

PARM2

Pattern

132

Return string #5

132

PARM3

Translate [*YES] #1

4

-

 

PARM4

Whole word [*YES] #3

4

-

 

PARM5

Offset #4

4

-

 

PARM6

Return String length

3

-

 

#1the scan function will be case sensitive unless you specify *YES in PARM3 in which case the string [PARM1] will be converted to uppercase before matching with the pattern.

It follows that if you specify *YES in PARM3 then your pattern should be entered in uppercase in order to find a result.

#2        the result returned in PARM1 will be ‘000’ if:

No match was found

The Pattern length is longer than the String length

The String is blank

The Pattern is blank

Otherwise the result returned is the position of the first character of the pattern in the string e.g. 028.

#3        the scan function will search for the pattern with an assumed leading and trailing blank.

E.g.

String = Here we go again, the aga is playing up.

Pattern = aga [with a leading space]

If you specify *YES in PARM4 then the Pattern start position returned will be 023 [for aga], if blank then it will be 012 [for again].

#4this is the Offset from the first character of the found string#2 to specify the start position for the data to be returned. If you wish the offset to be BEFORE the found string then the first character of this parameter must be ‘-‘.

Note: If no offset is specified, or the offset makes the start position > 132, then the start position of the found string will be assumed.

#5this will only be populated if you have specified a Return String length in PARM6.

Example

Position


        1         2         3         4

1234567890123456789012345678901234567890123456789

String

PARM1

The quick brown fox jumped over the lazy dog.

Pattern

PARM2

fox

The returned Pattern Start in PARM1 would be 017. Then depending upon the Offset & Return length you would get the following examples:

Offset

Return length

Return String

PARM5

PARM6

PARM2

‘-006’

‘005’

brown

‘004’

‘011’

jumped over

‘   ‘

‘010’

fox jumped