IF DIFF


The IF DIFF statement compares the current contents of a record (file name), field, group, or predefined field with its stored, default, or original value.

    ••••• IF DIFF  ••• •••••••••••••••••••••• ••• ••••••••••••••
    (1)            (2) (3)                    (4) (5)

(1) T/F execution conditions

(2) Application ID

(3) File name, field name, or predefined field

(4) Occurrence (constant/index)

(5) Comparison type (STORE, DEFAULT, or ORIGINAL)

Sets True/False Status Indicator

If the two values compared are different, the next level of the true/false status indicators is set to T; otherwise, it is set to F. See Chapter 4-2: True/False Status Indicators for details on using these indicators.

Using the Statement

The IF DIFF statement allows you to determine if the contents of the operand have changed from the comparison type value. The operand can identify a record (file name), an individual field or a group (field name), or a PDF. Valid comparison types are STORE, DEFAULT, and ORIGINAL and can be selected via Scan.. IF DIFF will compare the current value of the operand against the STORE/RESTORE area (STORE), the default record (DEFAULT), or the original (on-disk) buffer (ORIGINAL).

ORIGINAL is only valid for the PCF since APPX does not store the original on-disk values for other files (see notes below). To make it easier to use IF DIFF in a subroutine, you can omit the operand name if the comparison type is ORIGINAL (since that implies the PCF record).

IF DIFF will also populate the --- COMPARE memory file with a list of differences. If no differences are found, this file will be empty. If differences are found, the COMPARE file will hold one record for each changed field, composed of the following fields:

COMPARE FIELD NAME

X(22), primary key

COMPARE DESCRIPTION

X(30)

COMPARE CURRENT VALUE

X(80)

COMPARE OTHER VALUE

X(80)

COMPARE OFFSET

9(5)

COMPARE LENGTH

9(5)

The COMPARE FIELD NAME field will contain the name of the changed field. COMPARE DESCRIPTION will contain the descriptive name of the changed field. COMPARE CURRENT VALUE will contain the value of the field in the current record buffer, as converted by CNV TEXT. COMPARE OTHER VALUE will contain the value of the field in the other record buffer (store, default, or original) as converted by CNV TEXT. The COMPARE OFFSET and COMPARE LENGTH fields will contain the offset of the field within the record buffer and the length of the field, respectively

The following notes may provide a better understanding of how to use the ORIGINAL comparison type in this statement:

  1. Any process that has a PCF can compare to the original-record buffer.

  2. Since file-level event points have a PCF, they can compare to the original-record buffer.

  3. The original-record buffer is now shared between the file-level event points and the foreground process. Prior to the implementation of the IF DIFF statement in Release 4.2, you could modify a record in the file-level Post Read event point and the foreground input process would not notice that the record had changed.

  4. For file-level event points, each stream maintains its own original-record buffer.

  5. For release 4.2, APPX only keeps an original-record buffer for PCF files. However, this restriction may be lifted in a future release.

  6. The original-record buffer is managed in the manner described below:

  1. In Add mode, the default-record buffer is copied to the original-record buffer just before the Set Run-Time Defaults event point.

  2. In Inquire, Delete, or Change mode, the original-record buffer is copied from disk just before the Post PCF Read event point.

  3. For file-level event points, the original-record buffer is copied from disk just before the Post Read event point.

  4. In Change mode, the current-record is copied to the original-record buffer just before the Post PCF Update event point.*

  5. In Add mode, the current-record is copied to the original-record buffer just before the Post PCF Update event point.*

*Note: For process types other than Input, APPX never updates the PCF automatically, so rules 6.d and 6.e only apply to Input processes.