Programming for the Dup key

The system follows this procedure of duplicating entire fields.

When you press the Dup key, the IBM® i operating system handles the field as follows:

  • If the field is a character field, the data displayed in the field is returned to your program as is. A hex 1C is placed at the cursor position and in the remaining field positions to the right. (Hex 1C appears as an over-scored asterisk on the display.) The response indicator, if specified, is set on.
  • If the field is a numeric field and you specify a response indicator, a hex F0 is placed at the cursor position and in the remaining field positions. The response indicator is set on and returned to your program. If a response indicator is not specified, hex 1Cs are returned to your program.

In your program, you can duplicate entire fields (either character or numeric) with the following procedure:

  1. Specify two fields for each input-capable field on the display in DDS.
    1. Specify one field as an input-capable field. For this field, specify DUP with a response indicator.

      You might want to specify DUP with an option indicator that is off on the first display of the field. This prevents the workstation user from using the Dup key when the field is first displayed.

    2. Specify the other field as a hidden field (H in position 38).
  2. On the first output operation, set off an option indicator for DUP.

    This prevents the workstation user from using the Dup key.

  3. On the first input operation, move the input-capable field to the hidden field.

    This saves the typed value for later use.

  4. On each subsequent output operation, set the option indicator on for the DUP keyword.

    This allows the workstation user to use the Dup key.

  5. On each subsequent input operation, test the response indicator specified with DUP. If the response indicator is off, the input data should be moved to the hidden field. If the response indicator is on, you can use the existing value in the hidden field.
    Note: When using the DUP keyword in a subfile, an update operation should be performed after steps 3 and 5 to store the value of the hidden field into the subfile. This will be returned on the next read of that subfile record.
  6. Repeat steps 4 and 5 for subsequent data entry using the Dup key.

You can also duplicate character fields one character at a time by saving them in arrays, then moving the array one character at a time and checking for the DUP key indication of hex 1C.

You can achieve duplication of numeric fields one digit at a time by defining the field as character and eventually moving it to your numeric field after the hex 1Cs have been removed. You can test whether the Dup key has been pressed:
  • For numeric fields, a response indicator is required.
  • For character fields, a response indicator is optional.

The field will contain hex 1C at the cursor position and in the remaining positions if the Dup key has been pressed.