CHANGE (CHG, C)


The CHANGE command searches for a specified value or condition, and if found, changes the data to a new value. When you enter the CHANGE command without parameters, File-AID displays the CHANGE Command screen. The screen field names are shown in parentheses next to their corresponding parameter terms.

The command is available in the Edit function in all modes.

image2021-6-3_10-6-28.png

rel (Operator)

Relational operator that specifies the relationship the edit data must have to the val1 parameter in order to be changed. Valid entries for this parameter are:

EQ: Matches any string equal to val1 (default)

NE: Matches any string not equal to val1

LT: Matches any string less than val1

GT: Matches any string greater than val1

LE: Matches any string less than or equal to val1

GE: Matches any string greater than or equal to val1.

The rel parameter can be used with a val1 parameter (or a substitute asterisk), but not with the parameters VALID, INVALID, or ANY. When val1 is a character string, the comparison is executed according to the EBCDIC collating sequence.

val1 (From string)

Provides a value to be matched using the comparison specified by the rel parameter. When used with a /field-name or /field-number parameter, val1 is required to be compatible with the field declaration in the record layout.

File-AID does not perform any case conversion for DBCS (double byte character set) data.

The val1 parameter may be any one of the following data types:

  • Simple string: An alphanumeric character string that does not contain any single quotes ( ' ), double quotes ( " ), embedded blanks, or commas.
  • Delimited string: A simple string enclosed in single ( ' ) or double ( " ) quotation marks. Use delimited strings to search for characters that are not allowed in simple strings and in some instances, to enclose command keywords.

  • Simple and delimited strings are not case sensitive. Specify any combination of upper and lowercase characters for the search string and, regardless of the case, any combination of the specified characters is found. For example:

    CHANGE elm OAK or CHANGE ELM OAK
  • changes the next occurrence of the character string ’elm’, ’ELM’, or ’Elm’, for example, to ’OAK’.

    CHANGE elm OAK all or CHANGE ELM OAK ALL
  • changes all occurrences of the character string ’elm’, ’ELM’, or ’Elm’, for example, to ’OAK’.
  • To specify a keyword as val1 or val2 in the change string, you must enclose the string in single or double quotes:

    CHANGE ’ALL’ OAK all or CHANGE all "ALL" OAK
  • changes all occurrences of the character string ’ALL’ to ’OAK’.

    CHANGE ’’’ ’Q’ or CHANGE "’" "Q"
  • changes a single quote to a ’Q’.

    CHANGE ’"’ ’D’ or CHANGE """ "D"
  • changes a double quote to a ’D’.
  • Character string: A delimited string of characters preceded by the character C. A character string is case-sensitive, and matches or (when used as val2) replaces only an exact duplicate (including case) of the input string. For example:

    CHANGE C’Roman Emperors’ ’Czar of Russia’
  • finds and changes ’Roman Emperors’ but not ’roman emperors’ or ’ROMAN EMPERORS’.
  • Hexadecimal string: A delimited string containing an even number of hexadecimal digits (0-9, A-F), preceded by the character X. For example:
    CHANGE X’00’ X’F1’
  • Decimal string: A delimited string of decimal digits (0-9) preceded by the character F or H. The F or H may be followed by L and a decimal digit to specify the data length (from 1 to 8) in bytes. If the length is omitted, a value of 4 is assumed for F, and a value 2 is assumed for H. A decimal string matches the data against the binary representation of the decimal string for the specified length.
  • Packed string: A delimited string of decimal digits (0-9) preceded by the character P. The P may also be followed by L and one or two decimal digits to specify the data length (from 1 to 16) in bytes.

    Important

    When a packed string is used, the col1 parameter must be specified to indicate the location of the packed data.

  • File-AID matches only a packed data item of the specified length, commencing in the specified column, and containing the packed decimal representation of the decimal string. If length is omitted, the data matches a valid packed decimal data item with a length of 1 to 16 (containing the specified value).
  • Packed data test: The characters PL followed by one or two decimal digits to specify the data length (from 1 to 16) in bytes. The col1 parameter must be used to specify the location of the packed data. A packed data test searches for valid packed data starting in the specified column. If length is specified, the data must be a packed decimal number of the specified length. Use the NE relational operator to search for invalid packed data beginning in a specified column. Only the EQ or NE relational operators may be specified with a packed data test.
  • Text string: A delimited string preceded by the character T. Text strings are unnecessary because they are treated the same as delimited strings. File-AID supports the use of text strings to maintain consistency with ISPF/PDF.

The val1 parameter may be any one of the following data type strings:

Data type:

Example:

Simple

ABC

Delimited

'AB CD'

Character

C'Smith'

Hexadecimal

X'F1F2F3'

Decimal

999

Packed

P'59'

Packed data

PL4

Text

T'AnyCASE'

* (asterisk)

Enter an asterisk (*) in place of the val1 parameter to reuse the last value specified in a CHANGE, EXCLUDE, or FIND command.

VALID, INVALID

Changes valid or invalid data in a specified field. These values are mutually exclusive with the rel and val1 parameters. Data is considered valid if it conforms to the field declaration in the record layout.

A /field-name or /field-number parameter is required when one of these values is used. If one of these parameters is not specified, the VALID or INVALID keyword is interpreted as a simple string.

A successful search for valid or invalid data produces the message: EQ VALID CHANGED or EQ INVALID CHANGED. An unsuccessful search produces the message: NO EQ VALID FOUND or NO EQ INVALID FOUND.

ANY

Changes any value in a range of columns by specifying col-1, and optionally, col-2. Also changes any value in a field by using a specific field name.

If you specify col-1 without col-2, any value starting in col-1 is changed to string-2, based on the length of string-2. For example:

CHANGE ANY ABC 10

changes any value starting in column 10 and ending in column 12 to ABC. If you specify both col-1 and col-2, the entire value contained within, and including col-1 and col-2 is changed to string-2, with blank padding to the right, if necessary. For example:

CHANGE ANY ABC 10 20

changes any value starting in column 10 and ending in column 20 to ABCªªªªªª.

val2 (To string)

Specifies the new value to be substituted for data matching the condition specified by the rel and val1 parameters.

Data item length described by val2 and val1 must be the same.

This prevents inadvertent data misalignment in a record resulting from data substitution. Specifying a val2 parameter that differs in length from a val1 parameter produces the message: STRINGS NOT SAME LENGTH.

Important

The val2 parameter must follow the val1 parameter.

Any data type used for the val1 parameter can also be used for val2 as long as the two lengths are the same. In most cases, the same data type need not be used for both val1 and val2. The length of a decimal or packed string is not required because it is defined by val1.

* (asterisk)

Value for the val2 parameter that specifies File-AID to reuse the last value entered in a CHANGE command.

If the profile option CAPS is set to OFF, the exact value entered for val2 replaces val1, including case, although the search for val1 is conducted regardless of case. If the profile option CAPS is set to ON, val2 is changed to uppercase prior to replacing val1 (unless val2 is a character string specified with “C”).

lrange (Start range, End range)

Confines the CHANGE command to a specified line range (records). For the line range limits, use any combination of user-defined labels, system labels, or line numbers prefixed by a period.

If a single line label or line number is specified (or the same line is specified twice), File-AID limits the search to the specified line. Line range limits can be specified in any order. The line that occurs first in the data set is considered to be the lower limit of the line range.

Additional line labels may be defined by entering (in the sequence field to the left of the line to be labeled) a string starting with a period followed by one of the letters A through Y.

X, NX (Lines to search)

X restricts the CHANGE command to excluded lines; NX restricts the CHANGE command to nonexcluded lines. If the lrange parameter is also specified, File-AID scans only excluded (or nonexcluded) lines within the specified line range.

Use the EXCLUDE primary command or the X (exclude) line command to exclude lines. Excluding lines divides the edit data set into two subsets, either of which may be processed separately by the CHANGE command with the X or NX parameters.

NEXT, PREV, FIRST, LAST, ALL (Modifier)

Use the NEXT, PREV, FIRST, or LAST values to specify the starting point and search direction. The following table summarizes the functions of these parameters.

CHANGE Command Search Values

Parameter

Search Direction

Origin of Search

NEXT

Forward

Current cursor position

PREV

Backward

Current cursor position

FIRST

Forward

Start of data or specified line range

LAST

Backward

End of data or specified line range

Use the ALL parameter to process all lines (selected by rel and val1) that contain the specified data (within the lines defined by the lrange, X, and NX parameters). The ALL option is mutually exclusive with the NEXT, PREV, FIRST, and LAST parameters. If none of these values is specified and a line range has been specified, File-AID assumes a value of FIRST. If none of these values is specified and a line range has not been specified, File-AID assumes a value of NEXT.

col1, col2 (Start column, End column)

Specifies a valid single column (col1) or column range (col1 and col2). File-AID defaults to the current bounds settings if col1 and col2 are not specified. Specify a single column or column range to override the default column range. Data specified for a single column must begin at the col1 position. Data specified for a column range must be found within the specified range.

Important

The col2 parameter must follow the col1 parameter.

Specify the col1 and col2 parameters as integers. If the val1 or val2 parameters consist of the numbers 0 (zero) through 9, delimit the value of the val1 and/or val2 parameter to distinguish it from column numbers. Do not use col1 or col2 when the /field-name or /field-number parameter is used.

/field-name, /field-number (Field name, Field number)

The /field-name parameter specifies the data name given to the field in the record layout. The /field-number parameter specifies the number generated by File-AID for each data name in the record layout. If a name was specified in the record layout data set or XREF data set name fields on the Edit - Data set Specification screen, you can use a /field-name or /field-number parameter to confine the search to a specific data field.

The /field-name or /field-number parameter must be prefixed by a slash (/) to distinguish it from val, val2, or column range (col1 and col2) parameters. A field name can be fully qualified, partially qualified, or unqualified, but it must be unique. Each unique word of the field name may be abbreviated starting with the first letter. If an abbreviated field name is used, it must be unique.

Use a period to delimit levels of qualified names. If several maps are loaded, it may be necessary to include the member name or the 01-level name to uniquely identify a field. If so, precede the field name with the member name and/or 01-level name, also delimited with periods.

Specify either a /field-name or /field-number parameter when a VALID/INVALID parameter is used.

Important

When you use the /field-name or /field-number parameter with the ALL parameter, File-AID changes the first occurrence of the search string in each field. Subsequent occurrences of the same string in the same field can be changed by repeating the CHANGE command.

Example Field-Name Parameters

Search for a value in the FEDERAL field in the following record layout:

01 PAYROLL-REC
  02 NAME
  02 WITHHOLDING
    04 FEDERAL
    04 FICA
    04 STATE

Any of the following could be used as the /field-name parameter in the CHANGE command:

Fully-Qualified Name: /PAYROLL-REC.WITHHOLDING.FEDERAL
         Abbreviated: /PAY.WITH.FED
 Partially-Qualified: /WITH.FED
         Unqualified: /FED

If the WITHHOLDING item was modified by an OCCURS 12 TIMES clause (COBOL) or an ARRAY(12) clause (PL/I), the fourth instance of FEDERAL could be found by specifying a /field-name parameter of /FED(4).

A field name value that matches more than one field name in the record produces the message: AMBIGUOUS FIELD NAME.A field name value that does not match any record field produces the message: FIELD NAME NOT FOUND.

If a record layout was not entered on the Edit screen, specifying a field name or field number produces the message: FIELD UNDEFINED - NO MAP.

Important

/field-name, /field-number parameter usage is mutually exclusive with col1, col2 parameters.

Guidelines

File-AID performs a search without regard to case (upper/lower) for the CHANGE, EXCLUDE, and FIND primary commands with the following exceptions, in which case File-AID searches for the string exactly as entered:

  • If a case-sensitive search is specified by a delimited string of characters preceded by the character C.
  • When a Boolean operator other than EQ or NE is specified.
  • For a double-byte character string (DBCS) system.

Data to be replaced is defined either with the rel and val1 parameters or with the VALID or INVALID parameters. The new value is defined with the val2 parameter. The remaining parameters limit the command to specific lines and/or fields within lines, and specify which occurrence(s) of the specified data are to be replaced. A change is limited to the range of columns within the bounds, except when a column, column range, field name, or field number is specified.

The RCHANGE command executes the search in the same direction as the previous CHANGE command and changes the next instance of matched data. A repeated search using RCHANGE is not confined to the line range specified in a CHANGE command.

After a successful change, File-AID positions the cursor immediately after the last changed byte. An unsuccessful search produces the message: NO (rel)(val1) FOUND.

Unicode Considerations

For Unicode data, the CHANGE command has these restrictions:

  1. Only supports hex format.
  2. The parameters VALID and INVALID are not supported.
  3. In FMT mode and VFMT HEX OFF mode, the cursor does not point to the exact position of the found string.

Formatted Mode

Changes are not automatically confined to the currently selected record unless the appropriate CHANGE parameters are specified.

If the cursor is located within the data area of a field when you press Enter, the search is limited to that field. This technique may be used instead of specifying the /field-name or /field-number parameter.

CHANGE Command Screen

If you enter the CHANGE command without specifying any parameters, File-AID displays the following figure. Refer to the parameter descriptions beginning CHANGE (CHG, C) for a complete description of the fields on this screen.

CHANGE Command Screen

File-AID ------------------ CHANGE Command ------------------------------------
 COMMAND ===>

 Specify CHANGE operands:
    Operator         ===>         (EQ; NE; LT; GT; LE; GE)
    From string      ===>
    To string        ===>
    Modifier         ===>         (NEXT; ALL; FIRST; LAST; PREV)
    Lines to search  ===>         (NX = Nonexcluded; X = Excluded; Blank = all)


 Specify the Following Fields to Limit the Range of Search for this CHANGE:
    Field name      ===>
       or
    Field number    ===>
       or
    Start column    ===>         End column ===>          (Column number(s))
    Start range     ===>         End range  ===>          (Label or line number)


 NOTE: You may bypass this screen by entering the CHANGE command with operands:
 CHANGE  string         string2   (NEXT)   (NX)  (col-1 (col-2))   (range)
 CHG     (op) string              (ALL)    (X)   (/field name)
 C       VALID                    (FIRST)        (/field number)
         INVALID                  (LAST)
         ANY or *                 (PREV)


 

Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*