Find Command


The FIND command in ISPF is used in Edit, View, and Browse modes to locate specific strings or patterns in datasets or members. It is a powerful tool that helps users efficiently navigate large datasets by pinpointing exact data within specified criteria.

Key Features -

  • Search Flexibility: Supports case-sensitive and case-insensitive searches, column range limitations, and line range limitations.
  • Pattern Matching: Supports predefined patterns to search for alphanumeric, numeric, or special characters.
  • Label-Based Search: Define labels for lines and restrict searches to specific ranges using these labels.
  • Hexadecimal Search: FIND supports searching for hex-encoded strings.
  • Custom Search Modifiers: Search for words, prefixes, suffixes, or substrings.

Syntax -

FIND 'string' [range] [column-range] [options]
  • Column Range: Specify columns to limit the search area.
    Example: FIND XYZ 23 45 searches for "XYZ" between columns 23 and 45.
  • Labels: Use predefined or custom labels to restrict the search to specific lines:
    • .ZF: First line of the dataset.
    • .ZL: Last line of the dataset.
    • .ZCSR: Current cursor position.

Search Modifiers -

  • WORD: Searches for strings that are delimited by spaces or non-alphanumeric characters.
  • CHAR: Searches for any character sequence.
  • PREFIX: Finds strings immediately followed by other characters (no spaces).
  • SUFFIX: Finds strings immediately preceded by other characters.
  • HEX: Searches for strings specified in hexadecimal format (e.g., x'48454C4C4F' for "HELLO").
  • TEXT: Case-insensitive search (default).
  • CASE: Case-sensitive search (e.g., FIND C'ISPF').

Search Positioning -

  • FIRST: Finds the first occurrence of the string.
  • LAST: Finds the last occurrence of the string.
  • ALL: Highlights all occurrences and shows the count.
  • PREV: Finds the previous occurrence from the current position.
  • NEXT: Finds the next occurrence from the current position.

Repeating a Search -

Use FIND * to repeat the last search with the same string and direction.

Picture Clause Searches -

The Picture Clause allows finding patterns that match certain characteristics. Strings are enclosed in single quotes and preceded by P.

Picture Characters -

Character Description
@ Alphabetic characters.
# Numeric characters.
< Lowercase letters.
> Uppercase letters.
$ Special characters.
. Non-displayable characters.
= Any character, including blanks.
- Non-numeric characters.
~ Non-blank characters.

For example, FIND P'NAME#' ALL locates all occurrences of strings like NAME0, NAME1, ... NAME9.

Examples -

Scenario - Find all occurrences of "HELLO" in the program.
Find Command If the text found, all the occurrences of text highlighted in white and cursor will be placed at the first occurrence of the text.
Find Command Press PF5 key to find the next occurrence.
Find Command

More Examples -

CommandFunction
FIND 'ABC' Locates the first occurrence of the string ABC.
FIND 'XYZ' 10 20 Searches for XYZ in columns 10 to 20.
FIND 'DATA' 5 15 Finds the string DATA between lines 5 and 15.
FIND 'ERROR' .A .B Locates the string ERROR between labels .A and .B.
FIND 'USER' ALL Highlights all occurrences of USER and displays their count.
FIND WORD'VALUE' Finds VALUE as a complete word, ignoring substrings.
FIND PREFIX'123' Locates strings starting with 123.
FIND SUFFIX'END' Finds strings ending with END.
FIND * Repeats the last executed FIND command.
FIND 'string' .A .B 30 45 Searches for "string" between labels .A and .B and within columns 30 to 45.
FIND P'NAME#' ALL Finds all occurrences of NAME0, NAME1, ..., NAME9.

Default Behavior of FIND -

  • Searches from the current cursor position (.ZCSR) to the end of the dataset (.ZL).
  • Searches are case-insensitive by default (TEXT).
  • The NEXT direction is used unless specified otherwise.