Previous Topic: SAYWHAT()

Next Topic: SCRASID()

SCANSTR()

The SCANSTR() function scans a text string for complex patterns.

Syntax

The SCANSTR() function has this syntax:

{0|1} = SCANSTR(pattern,string,[vldc],[fldc])

Arguments

The SCANSTR() function takes these arguments.

0/1

If the specified pattern is present in the scanned string, a 1 is returned. If the string is not found, a 0 is returned.

pattern

Pattern character string to be searched for. The pattern is composed of any combination of characters and placeholders (VLDCs and FLDCs).

string

Text string to be scanned for the pattern.

vldc

(Variable-Length Do not-Care) A character that, when appearing in the pattern, will be taken to represent an arbitrary string of any length (including zero).

Default: & (ampersand)

fldc

(Fixed-Length Do not-Care) A character that, when appearing in the pattern, will be taken to represent exactly one arbitrary character.

Default: * (asterisk)

Usage Notes

All usage notes assume that the VLDC character is & and the FLDC character is *.

Return Codes

The SCANSTR() function produces these return codes:

101 - 104 ARG n MISSING OR INVALID

120 SCAN PATTERN TOO LONG OR COMPLEX

Example

/*  Unpack a julian date from ISPF statistics format */
1 == scanstr('&cat&','cats and dogs')
1 == scanstr('&c*t&','dogs and cats')
0 == scanstr('&Cat&','cats and dogs')
1 == scanstr('&CAT&',translate('Cats and Dogs'))
1 == scanstr('&cat&dog&','cats and dogs'
1 == scanstr('cat&d**s','cats and dogs')
1 == scanstr('&cat&dog&','complete catalog of doggerel')