FIND search for string in the file data/names

FIND [n,] param [=W datei [, E|O ] ] [, N] [, NO] [, C|NC] [, F] [, SKIPF] [, TYPE= t1, t2,...]

Selection of files/library elements/Job variables which contain one or more search items in their name or data contents.

The resulting records with their file names can also be written to a printable list file (=W file). A value will appear in the file list in the User Option column which will indicate the number of records in which the specified search condition was found at least once.

n Restrict the search to the first n records. (Standard: all records).

param simple or multiple search statement.

simple search statement: [ col ] [p] item

col Column range in which the search item should begin.

:col1-col2: The first character of the search string must begin in the column range between col1 and col2.

:col1: The string must begin in col1.

>:col1: | <:col1: The string is sought in the range from col1 to the end of the record (>), or from the beginning of the record to col1 (<).

Standard: The search is carried out from the beginning of each record to the end.

p >    Search for a character string > item

<    Search for a character string < item

-    Search for a character string not equal to item

Standard: Search for a character string = item

item Search string: C'string' | L'string' | X'string'

C'string' can be abbreviated to 'string'.

L'string': Lowercase letters in string are not converted to uppercase.

If string contains single quotes ('), these should be entered twice ('').

Multiple Search - Format 1: param [op param] [op param] .....

param simple search argument following the syntax described above.

op Logical operator joining the two simple search arguments.

  , Or operator.

  + And operator.

  *[n] Wildcard operator: An And operation, but in addition, the second search string must appear after the first in the record. Optionally, there must be n positions between the first and second search strings.

Any number of search arguments may be joined by Or/And/Wildcard operators.

Notes:

The And/Or operation is restricted to a record. This means that both of the search strings must occur in the same record.

A full description of the logical operators can be found on page 8-.

Multiple Search - Format 2: ( )

Entering () will display a special search mask. This mask provides the user with 18 lines in which to enter a series of complex search arguments. A description of this mask may be found on page 8-.

Multiple Search - Format 3: %name | %? [, jrsave]

%name is a description of a parameter set which contains a complex set of search arguments which had been previously been saved using the SP %name command. For further information, see page 8-.

%?: All available parameter sets will be displayed in a list. One of those displayed can be selected by marking it.

jrsave is the name of file to which the parameter set is saved. Standard: CFS.JRSAVE [.jobname] .

Multiple Search - Format 4: ( s-fil )

s-fil is the name of a SAM file in which the search arguments are contained. For further information, see page 8-.

Multiple Search - Format 5: ? | ?,%name

Entering ? will display the last search argument to have been used.

Entering ?,%name will display the search mask pre-filled with the search arguments contained in %name (see Format 2).

Writing away the Search Results

=W file [, E | O ] [, N ] [, NO ] [, NC]

The search results are written away to a printable output file. The names of the respective data objects are also written to the file. If the NO option (see below) is specified, only the names are saved.

E The Write file is opened with Open=Extend.

O The Write file is opened with Open=Output.

The =W file [, E | O ] option can also be specified in the search mask (see above: Multiple Search - Format 2), or in the s-fil (see above: Multiple Search - Format 4) at the end of the last search string.

FIND ..., N The names of the files/library elements currently being searched are displayed on the screen.

FIND ..., NO Names Only. Only the names of the files/library elements are searched for the specified string. The names of the files or elements which contain the string are written to the Write file. The primary area of application for the NO option is in searching multiple libraries for elements of a particular name. For a demonstration of this, see Example 2 below.

FIND ..., NC No Check for Continuation. Checking for continuation of a BS2000 command, or a macro or source program statement, is suppressed.

Normally, i.e. if the NC option is not specified, procedure/macro/source records are treated as a logical unit if they are linked with a continuation character. If the search string is found in such a record, then all lines forming the logical record are written to the Write file. The line containing the search item is flagged with an 'X' in the second column.

FIND ..., C All procedure/macro/source code records linked with a continuation character will be treated as a logical unit. This means that, for example, a compound search string such as 'FCB'*'BLKCTRL=DATA' will be flagged as a hit, even if the partial string 'FCB' occurs in one line, and the partial string 'BLKCTRL=DATA' in a continuation line.

If the option of writing to a file was selected, all records belonging to a logical unit which was flagged as a hit will be written. If the search string was contained wholly in a partial record, then this partial record will be flagged with an 'X' in column 2.

FIND ..., F Find First. The search will be terminated after the first item has been found. One hit will be recorded. This provides a quick way of determining whether the data object contains the specified string or not. By default, the whole file is searched for the string, even after a hit has been found. In this case, the number of hits will show the correct value.

FIND ..., SKIPF

Skip Found. The data object in which the search string does not appear in any record will be transferred to the list.

FIND ..., TYPE=t1,t2, ...

This parameter is only relevant for searching files which represent PLAM libraries.

The search will then be restricted to elements of the specific type within that library. Example: TYPE=J or TYPE=J,S

By default, all elements in the library will be searched, irrespective of type.

Notes:

The REWR command (Rewriting from the Write file to the original source file) should be noted in conjunction with the Write option (=W ..). This Rewrite command (see page 7-) provides the reverse mechanism to the Write option.

Files saved to the Write file will not be sorted in alphabetical order.

If neither the E nor the O option (Extend/Overwrite) is specified after the name of the Write file, then the following rules apply:

If the Write file is being accessed for the first time in this current CFS process, then it will always be opened in O (Overwrite) mode; i.e. the file will be created or overwritten.

If the same file is specified in successive selection runs, then it will be opened in Extend mode.

The E/O option can be used to set an open mode that differs from the standard value.

Tape files and migrated HSMS files are excluded from the FIND user option.

CFS will search BS2000 files that represent libraries at the library element level, and not at the individual record or block level. The FIND User Option will provide the total number of occurrences of a particular search string across all elements in a library, or the number of library element names.

Examples:

FIND 'FLAG'*'STATEMENTS'=W FIL.FLAGS

All files/library elements are searched for the occurrence of at least one record which contains the string 'FLAG' and somewhere after that the string 'STATEMENTS'. The resulting records are written to the SAM file, FIL.FLAGS.

FIND 'A1015'=W L.FNDLIST,NO

Problem: A source program named A1015 exists in multiple libraries of the owners userid, or across the system, and needs to be found. The libraries are first pulled into a list by specifying LIB in the FILENAME-SELECT field. The FIND User Option specified above can then be used to search the names of all elements of the libraries for the occurrence of the string 'A1015'. The element name providing a search hit, together with its respective library name is written to the file L.FINDLIST. Only those libraries will be listed in the file list that contain at least one element with the specified name. The user can then display the table of contents of each library with the NP or NPF Action Code.

FIND :1:'$T'

The Job variable must begin in column 1 with '$T' (i.e. Monitor Job variables indicating a normal job termination).

Further examples of search arguments, in particular the logical joining of multiple search arguments, can be found in Chapter 8 "CFS Display/Editor" on pages 8- to 8-.