FIND primary command

The FIND primary command finds and displays the next, first, or previous occurrence of a character string (or field value) in the data being edited or browsed.

When an occurrence of the string is found, FM/IMS places the cursor at the beginning of the string. If necessary, it scrolls the data to bring the string into view. All occurrences of the string on the displayed page are highlighted.

For date and time fields that are displayed using the output format defined in the view, FM/IMS searches the displayed values for the string specified with the FIND command.

When you are using a view, the setting of the SHOW SUP command affects the segments that are searched. With SHOW SUP OFF, only those segments matching the current segment type and layout are searched. With SHOW SUP ON, the search is not limited to segments of the current segment type and layout.

To repeat a FIND with the same parameters, press the RFIND function key (F5), or enter the RFIND primary command.

If you enter FIND *, then the FIND is repeated with the same string argument, but with all other parameters set to their default value. You can supply particular parameter values if you wish, for example FIND * PREFIX.

The FX command displays the Extended Command Entry panel in which you can enter long arguments that may not fit on the Command line.

Syntax


1 Find
1 FX
1 /
2? SEGment(segment-name)
2? GET(n)
2 
3.1! SCOPE
3.1 Db
3.1 Rec
3.1 DEPendent
3.1 *
3.1 string
3.1! NEXT
3.1 ALL
3.1 FIRST
3.1 PREV
3.1! CHARs
3.1 PREfix
3.1 SUFfix
3.1 WORD
1  %column range
1  %field list or range
column range (CHAR, HEX, and LHEX formats only)

1 col1 ?col2
field list or range (SNGL or TABL display format)

1 ! #ALL
2.1 (?+ , #field)
1 (?+ , #field_1 - #field_2)

You can specify the parameters in any order.

segment-name
When the SEGMENT parameter is specified, the search is restricted to occurrences of the segment type, segment-name. The parameter is only permitted when SHOW SUP is on, or when you are not using a view.
GET(n)
Limits the number of segments searched to n.
SCOPE
Search range is the current scope.
DB
Search the entire database.
REC
Search is restricted to the current database record.
DEPENDENT
Search is restricted to the dependents of the current segment. The parameter is only permitted when SHOW SUP is on, or when you are not using a view.
* (asterisk)
Uses the search string specified on the previous FIND command as the search string.
string
The string being searched for. The string can be:
  • No more than 50 characters long, unless Find extended is used, in which case the limit is 100.
  • An empty string (not specified). The search string specified on the previous FIND or CHANGE command is used as the search string.
    Note: A FIND ALL with no search string specified performs a RESET FIND, turning off any highlighting from previous FIND or CHANGE commands.
  • A character string not starting or ending with a single quotation mark and not containing any embedded blanks or commas. The case of the string is ignored. Uppercase and lowercase representations of the same character match. For example Mixed matches MIXED.
  • A character string enclosed in single quotation marks. The string can contain blanks and commas. The case of the string is ignored.
  • C followed by a character string enclosed in quotation marks (C'Frog'), or a character string enclosed in quotation marks followed by C ('Frog'C). The string can contain blanks and commas. The string must match exactly (including case).
  • P preceded or followed by a picture string enclosed in single or double quotation marks to describe a type of string to be found rather than the exact characters. It can contain blanks, alphabetic and numeric characters which represent themselves, or any of the special characters listed here, each of which represents a class of characters:
    =
    Any character.
    @
    Alphabetic characters.
    #
    Numeric characters.
    $
    Special characters.
    & notsym;
    Non-blank characters.
    .
    Invalid characters.
    -
    Non-numeric characters.
    <
    Lowercase alphabetics.
    >
    Uppercase alphabetics.

    Examples of picture strings used with the FIND command:

    find p'.' 73 80
    Find invalid characters in columns 73 to 80.
    find p'###'
    Find 3-digit number (for example, 101 but not 99).
    find '@1'p 1
    Find label a1,b1,c1, (and so on) in column 1.
    find p'<'
    Find lowercase alphabetic character.
    find p'¬' 72
    Find non-blank character in column 72.

    When this notation is used, numeric, bit and unicode fields (for SNGL and TABL display formats) are excluded from the search process.

  • X followed by a hexadecimal string enclosed in single quotation marks (X'C1C2').
  • A numeric value (SNGL or TABL display format only). The algebraic value of string must match the algebraic value of the numeric field. The lengths (number of digits) of string and of the numeric field are not significant. Similarly, the data type of the numeric field is not significant. For example, a string of 123 matches a packed-decimal field containing 00123 or a floating-point field containing 1.230E+02. An unsigned value in string is considered to be positive.
NEXT
The FIND command searches for the next occurrence of the string, string, in the search range, starting at the cursor location (if the cursor is within the data portion of the display), or at the top of the displayed page (if the cursor is outside the data portion of the display).

If string is not found by the end of the search range, or if the cursor location is after the last segment in the search range, FM/IMS displays a message indicating that the end of the search range has been reached and redisplays the page that was displayed prior to the search. To resume the search from the top of the search range, use the RFIND (F5) primary command.

FIRST
The FIND command searches for the first occurrence of the string, string, in the search range, starting at the beginning of the first segment in the search range.

If string is not found in the search range, FM/IMS displays a message indicating that the string was not found and redisplays the page that was displayed prior to the search.

ALL
The FIND command searches for all occurrences of the string, string, in the search range, starting at the beginning of the first segment in the search range and continuing to the end of the search range.

If string is found one or more times, FM/IMS places the cursor at the beginning of the first occurrence and displays a message indicating how many times the string was found.

If string is not found in the search range, FM/IMS displays a message indicating that the string was not found and redisplays the page that was displayed prior to the search.

PREV
The FIND command searches for the previous occurrence of the string, string, starting at the cursor location (if the cursor is within the data portion of the display), or at the end of the segment preceding the first segment being displayed (if the cursor is outside the data portion of the display).

If the top of the search range is in the sliding window, the FIND command searches to the top of the search range. If the top of the search range is not in the sliding window, the FIND command only searches to the top of the window.

Note: When you reach the top of the search range or the top of the window, the RFIND (F5) command does not resume searching from the bottom of the search range.
CHARS
Matches the search string anywhere in the data.
PREFIX
Matches the search string wherever it appears as a prefix in the data. To be a prefix, the matched text must be preceded by a non-alphanumeric character or be the start of a line or field, and must be followed by an alphanumeric character.
SUFFIX
Matches the search string wherever it appears as a suffix in the data. To be a suffix, the matched text must be preceded by an alphanumeric character, and must be followed by a non-alphanumeric character or be the end of a line or field.
WORD
Matches the search string wherever it appears as a word in the data. To be a word, the matched text must be preceded by a non-alphanumeric character or be the start of a line or field, and must be followed by a non-alphanumeric character or be the end of a line or field.
col1
The starting position of the search. If col1 is specified without col2, string must start in col1 to be found. If both col1 and col2 are specified, string must be completely contained with the designated columns.
Note:
  1. You can only specify column ranges when data is in CHAR, HEX, or LHEX formats. You cannot specify column ranges when data is formatted using TABL or SNGL format.
  2. When column ranges are specified and the data is displayed in SNGL or TABL formats, the search is performed in the order that the data occurs, which may not be the order that fields are displayed in. Numeric field values are not considered in this type of search.

When column ranges are specified, then a string comparison is performed, even for numeric fields.

col2
Indicates the ending position of the search.
Note: If col2 is larger than the segment size, the segment size is used.
#ALL
Each field is searched according to its template attributes.
#field
The field reference number for a field in the layout. This applies to TABL and SNGL format.

To specify more than one field reference, they must be either enclosed in parentheses (optionally separated by commas), or separated by commas but without any intervening spaces. For example, (#17 #22), (#17, #22), and #17,#22 are valid field reference specifications.

For alphanumeric fields, the string is found if it is completely contained within one of the designated fields. For example: FIND ALL xxx #5,#6 finds all segments of the currently formatted type containing "xxx" within either of the fields with field references #5 and #6.

For numeric fields, the string is found if the value of either of the numeric fields is equal to the value specified by the string.

For example, FIND ALL 123 #8,#9 finds all segments of the currently formatted (numeric or character) type:
  • Containing the value 123 in either of the numeric fields with field references #8 and #9
  • Containing the string 123 in either of the character fields with field references #8 and #9
#field_1
The first field reference of a range of fields. It cannot be subscripted. If the #field_1 field reference value is less than the lowest displayed field reference value, the lowest displayed field reference value is used.
#field_2
The last field reference of a range of fields. It cannot be subscripted. If the #field_2 field reference value is greater than the highest displayed field reference value, the highest displayed field reference value is used.

The #field_1 and #field_2 field reference values must be separated by a hyphen (-). Spaces are permitted between the hyphen and the field reference values.

If #field_1 is a higher value than #field_2, the search process reverses the operands.

Figure 1. Extended Command Entry pop-up panel for the FIND command showing contiguous nature of entry lines
Process   Options   Utilities   Help
  ──────────────────────────────────────────────────────────────────────────────
FM/IMS                        Edit : IMS Database DJ1E
            Autosave OFF SHOW SUP ON  Scope ALL    Col 1          Format CHAR
   ┌───────────────────── Extended Command Entry ──────────────────────┐ DATE
   │                                                                   │
   │ Complete typing the FIND command and press Enter.                 │
   │                                                                   │
 0 │ FIND    ===> 'THE EXTENDED FIND CAN BE USED TO SEARCH FOR STRIN   │
 0 │         ===>  GS UP TO 100 CHAR LONG' PREV_____________________   │
 0 │         ===>  _________________________________________________   │
 0 │         ===>  _________________________________________________   │
 0 │         ===>  _________________________________________________   │
 0 │                                                                   │
 0 │                                                                   │
 0 │  F1=Help    F2=Split   F3=Exit    F9=Swap   F12=Cancel            │
 0 └───────────────────────────────────────────────────────────────────┘ 9/2020
    ___  2    LINKSUB   O'CONNOR
    ___  2    LINKSUB   SAMSON
    ___  2    LINKSUB   SOUTH FREMANTLE
    ___  2    LINKSUB   WHITE GUM VALLEY
    ___ 1     SHIRE     KALGOORLIE          W60500012.`....................o.
    ___  2    SHIRENP   .......b...
    ___  2    LINKSUB   HANNANS
    ___  2    LINKSUB   KALGOORLIE
    ___ 1     SHIRE     MOUNT MAGNET        070400399.............. ..... ...
    ___  2    SHIRENP   ...........
    ___  2    LINKSUB   MOUNT MAGNET
    ___  2    LINKSUB   MOUNT MAGNET SHIRE
 Command ===> fx___________________________________________________ Scroll CSR
  F1=Help      F2=Format    F3=Exit      F4=CRetriev  F5=RFind     F6=RChange
  F7=Up        F8=Down      F9=Swap     F10=Left     F11=Right    F12=Cancel

If the MAXGN option has been set to a nonzero value at your installation, FM/IMS counts the number of segments read during the search and displays the Search Interrupt window when the count equals the value specified for MAXGN. The Search Interrupt window gives you the option of continuing or discontinuing the search. If you elect to continue the search and the search is not over when a further MAXGN segments have been read, the Search Interrupt window is redisplayed and you have the option once again of continuing or discontinuing the search.

There are two variants of the Search Interrupt window. Search Interrupt panel - search string not found shows the window that is displayed when no instances of the search argument have been found. You have three options:

  • To continue the search.
  • To discontinue the search and display data from the position prior to the search.
  • To discontinue the search and display data from the current search position.
Figure 2. Search Interrupt panel - search string not found
┌───────────────────── Search Interrupt ──────────────────────┐
│ Command ===>                                                │
│                                                             │
│                                                             │
│                                                             │
│ 100 segments searched.                                      │
│ Search argument xcv found 0 times.                          │
│                                                             │
│ To continue the search, press the ENTER key.                │
│                                                             │
│ To discontinue the search and display data from the         │
│ position prior to the search, enter the CANCEL command.     │
│                                                             │
│ To discontinue the search and display data from the current │
│ search position, enter the EXIT command.                    │
│                                                             │
│                                                             │
│                                                             │
│                                                             │
│                                                             │
│                                                             │
│  F1=Help        F2=Split       F3=Exit        F7=Backward   │
│  F8=Forward     F9=Swap       F12=Cancel                    │
└─────────────────────────────────────────────────────────────┘

For FIND...ALL requests, the search is not over when one instance of the search argument is found.

Search Interrupt panel - search string found shows the window that is displayed when instances of the search argument have already been found. If you elect to discontinue the search when instances of the search argument have already been found, FM/IMS will display data from the position of the first instance of the search argument, as it would if the search had run to its completion.

Figure 3. Search Interrupt panel - search string found
┌───────────────────── Search Interrupt ──────────────────────┐
│ Command ===>                                                │
│                                                             │
│                                                             │
│                                                             │
│ 100 segments searched.                                      │
│ Search argument wa found 6 times.                           │
│                                                             │
│ To continue the search, press the ENTER key.                │
│                                                             │
│ To discontinue the search and return to the data display,   │
│ enter the EXIT or the CANCEL command.                       │
│ (The first search argument found will be displayed at the   │
│ top of the screen.)                                         │
│                                                             │
│                                                             │
│                                                             │
│                                                             │
│                                                             │
│                                                             │
│                                                             │
│  F1=Help        F2=Split       F3=Exit        F7=Backward   │
│  F8=Forward     F9=Swap       F12=Cancel                    │
└─────────────────────────────────────────────────────────────┘

Availability

Related tasks and examples

The FIND command can be entered using any abbreviation of the command (for example, F or FI), or by entering the forward slash ("/") character.

Extended Command Entry pop-up panel for the FIND command showing contiguous nature of entry lines shows the Extended Command Entry pop-up panel for the FIND command. In this example, FM/IMS finds any previous occurrences of a long string.