![]() |
- Search for character strings (single search argument)
S [-] [n] ,[col] [r] item [, R] [, NC] [,SR]
A search is made for the specified character string starting from the first displayed record to the end/beginning of the file. The window is positioned on the first record to contain the search string. A Search command to find the next occurrence of the string is automatically placed in the command field.
Pressing the DUE1/ENTER key (sending this suggested command) will continue the search.
- Backward Search: The search proceeds from the first displayed record towards the beginning of the file.
Standard: Search towards the end of the file.
n Number of records to which the search should be restricted.
Standard: an unrestricted number of records.
col Column range in which the character string should be found.
:col1-col2:
The first character of the search string must begin in the range between col1 and col2.
:col1:
The character string is only sought in the specified column col1, and must begin there.
>:col1: | <:col1:
The character string will be sought in the range from col1 to the end of the record (>:col1:), or from the beginning of the record to col1 (<:col1:).
Standard: Search the entire column range (from column 1 to the end of the record).
r > | < | -
> Search for a character string > item
< Search for a character string < item
- Search for a character string not equal item
Standard: Search for a character string = item.
item Search string: C'string' | L'string' | X'string' | A'string'
C'string' can be abbreviated to 'string'. In many cases, even the quotation marks can be omitted. See the Notes.
L'string': Lowercase characters in string are not converted to uppercase.
If string contains quotation marks ('), then these should be doubled ('').
A'string': During the search, no distinction is made between uppercase and lowercase.
Example: The search string A'CFS' will return a hit if the record contains the string 'CFS' or 'cfs' or any combination of uppercase or lowercase.
The Search command also offers the possibility of specifying multiple search arguments linked with and/or/wildcard syntax. The syntax is a continuous sequence of the search arguments described in this section, and will be described in detail in a following section entitled "Search for Character Strings (Multiple Search Arguments)".
R Reverse. The search within the records will not proceed as usual from left to right, rather from right to left. If this mode is used, it is not possible to use And, Or or wildcard operators to link multiple search conditions.
NC No Columns. In DL mode (Display Long), the column positioning for a hit is suppressed for the current search (same as in DS mode). The optional parameter NC of the DL command functions similarly). DL,NC will set the NC mode for all following search commands in the current file.
SR Single Record. This indicator is only relevant for a negative search, i.e. when searching for a string other than the value specified (e.g. S,-X'00').
By default, when conducting a negative search without specifying a column range, a record will only be recorded as a hit if the search string does not appear in the complete record.
In SR mode, the first instance in the record of the non-appearance of the search string will be recorded as a hit. Entering the option R (see above) will automatically enable SR mode.
Notes:
When entering the column range col in the search statement, certain differences to entering column ranges in EDT should be noted:
1) :col1-col2: means that the argument enclosed in quotation marks must begin within the specified column range.
In EDT, the search argument must be wholly contained within the column range.
2) :col: means that the search argument enclosed in quotation marks must begin exactly at the specified column.
Entering a single column in EDT in the form :col: causes the search to proceed from :col: to the end of the record. In CFS this is achieved by entering >:col2:, whereby col2=col-1. By entering <:col:, a search can be made from the beginning of the record to col.
In most cases, string can be entered without the quotation marks (S,string). The quotation marks need only be specified if string contains spaces, or is followed by a replacement string (page 8-), or a Write command (page 8-).
Once the search argument has been defined, it is valid for all succeeding S commands, and need not be re-entered. It remains valid until a new string needs to be found.
If the user is only interested in the number of hits in the file, this can be achieved by entering the command S,'string'='' (in Non Modify mode only). In this case, only the number of hits found up to the end of the file is displayed.
A particularly long search can be interrupted by pressing the K2 key (branch to BS2000 command mode), and then entering the command /INTR R. The window will be positioned at that point in the file that was last read.
PAM: Search over Block Boundaries
When searching PAM files, the string does not have to be contained completely within a data block. If the string (e.g. 'DATABASE') begins at the end of a PAM block and is continued at the beginning of the next PAM block (e.g. 'DA' + 'TABASE'), then this combination will be recognised by CFS and flagged as a hit.
Examples:
S,C'XYZ'
Search from the first displayed record to the end of the file for the character string C'XYZ'.
S,C'C'' '''
Search for the character string C'_' over the whole file (Quotation marks in the search string must be doubled).
S,L'File'
Search all data records for the character string 'File'. The lowercase characters contained within the string are not converted before the search begins.
S,:73:-' '
Search in column 73 of each record for any character other than a blank. Records with fewer than 73 columns will not be flagged as a hit.
S,:1:>X'0054'
To detect records of a specific length, enter the Offset command O-4 to display the record length field. The above Search command for a RECFORM=V file will then find all records whose length, including the record length field, is greater than 84 bytes.
S10,:100-200:X'47'
Search the next 10 records in the column range 100 - 200 for the string X'47'.
S,'CFS'=''
In Non Modify mode: The number of records in which the string 'CFS' occurs at least once is counted. No replacement of the search string takes place in the file in Non Modify mode.
S,'CFS'='',A
In Non Modify mode: The total number of hits are counted.
A: multiple occurrences in one record are all counted.
In Modify mode, each occurrence of the search string is deleted in an ISAM file.
S,''
The length of the first record in the window is displayed in the commentary line (search to the end of the record).