DITTO command -- Scan file for a string
Scans records of a file for a specific string. The string may consist of a string of characters or a string of hexadecimal digits. Multiple occurrences of the string within one physical record are found. If a match is found, the starting position of the match within the record is output. The starting position is defined as the physical record number followed by the byte offset within the record. The byte offset and physical record values are displayed as zero, relative with respect to the starting position of the DITTO device.
- DEVTYPE
- Device type. Specifies which input/output device is to be processed. Valid values are:
= INPUT: Input device = OUTPUT: Output device
- NRECS(--)
- Number of records. The number of physical records to be scanned. The default is to scan records until the end of file is reached.
- TEXT
- Text string. The string to be searched for within the file. The text string may be entered as a string of ASCII characters or as a string of hexadecimal digits.
If the string is entered as ASCII characters, the string is case dependent. For example the string "a" is not equal to the string "A."
- TEXTTYPE
- Text type. Valid values are:
= CHAR: String of ASCII characters = HEX: String of hexadecimal digits
- OFFSET(0)
- Offset value. OFFSET represents the byte offset, relative to zero, where the scan field starts in each record processed.
- PRINT(TERM)
- Output destination. The destination of the output.
= TERM: Terminal. Output is sent to the user's terminal. = LP: Line printer. Output is sent to the printer defined by $PRINTER. = Filename: User-supplied filename. Output is sent to the user-supplied file with the extension ".prt".
The user has specified to scan the first ten physical records of the input device for the character string "allocated 1." The scan for each record begins with the tenth byte within the record.
From the input parameter DEVTYPE, it is determined on which device the scan is to be performed. The scan string is converted from the character or hexadecimal format into an array of byte values. The appropriate DITTO device is opened. Physical records are read until an end of file or the number of records specified is reached. Each record is searched for the scan string starting at the specified byte offset. If a match is found, the record and byte offset are written to the specified destination. Multiple matches within records are reported.