@SCRIPT
                   Record select/delete function.

A.  General description.

    This function allows data records to be selected/deleted based on
    statements in an Ascii script file.  The statements in the script file
    may be written as 'if' statements similar to basic or C language, etc.
    A full set of logical and arithmetic operations are supported as well
    as nested parentheses.  There is no specific limit to the number of
    levels of nesting or statement length.  The routine uses stack space
    dynamically, so the limitation is when the stack is overrun.  In this
    case the end user my increase the stack space on his copy of the .EXE
    program by using the DOS utility EXEMOD.

B.  DEFINE statements.

    Fields to be accessed within the data record must be defined using this
    statement.  The statement format is as follows:

        DEFINE field_name location,length,type

    field_name - The name assigned to this field.  It must start with an
                 alphabetic character and must be from 1 to 19 characters long.
                 This name is used in the IF statements to refer to the data
                 at this location in the input record.

    location   - The location of this field within the input record relative
                 to one.

    length     - The length of this field in bytes.

    type       - The type of data that this field contains.  This must be one
                 of the following:

                 PK   - Packed decimal
                 LB   - Binary with least significant byte first
                 HB   - Binary with most significant byte first
                 SC   - Signed Ascii or Ebcdic numeric character field.
                        This means the field may contain an actual '+' or '-'.
                 UC   - Unsigned Ascii or Ebcdic numeric character field.
                 ZN   - Ebcdic zoned decimal
                 ASC  - Ascii character field
                 EBC  - Ebcdic character field
                 HEX  - Hex byte field

C.  IF statments.

    The format of this statement is as follows:

        IF (item [oper item] ...) action

    item  - An item to evaluate.  Must be one of the following:

            1)  A record field name previously defined with a DEFINE statement.
                A field name must be defined before being used but it is not
                necessary for all of the DEFINE statements to preceed all of
                IF statements.

            2)  A signed or unsigned numeric constant.  Numeric calculations
                are limited to the value which may be contained in a 32 bit
                number, about 9 decimal digits.

            3)  A character constant which may be one of the following:

                A'....'  Ascii character string.
                E'....'  Ebcdic character string.
                H'xx xx' Hex byte string.

            4)  A parenthesized expression with the following general format:

                (item [oper item] ...)

    oper - An arithmetic or logical opertion as follows:

        symbol  symbol  symbol  (alternate symbols for the same operation)

          *                     Multiply                Level 1
          /                     Divide                  Arithmetic
        --------------------------------------------------------------------
          +                     Add                     Level 2
          -                     Subtract                Arithmetic
        --------------------------------------------------------------------
          <             LT      Less than               Level 3
          <=    =<      LE      Less than or equal
          =             EQ      Equal
          >=    =>      GE      Greater than or equal   Comparison
          >             GT      Greater than
          <>    ><      NE      Not equal
        --------------------------------------------------------------------
          &             AND     Logical and             Level 4
          |             OR      Logical or              Logical

        In evaluating the expression within one set of parentheses, all
        level 1 operations are evaluated first (from left to right), then
        all level 2 operations, etc.

    action - This specifies what action to take when the IF expression
        evaluates as TRUE.  It must be one of the following:

        ACCEPT - Process this record.
        REJECT - Discard this record.

D.  How expressions are evaluated.

    1)  Innermost level of parentheses are evaluated first.

    2)  Within one level of parenthesis, terms are combined working from
        left to right.  All level 1 operations are done first, then starting
        at the left again all level 2 operations, etc.

    3)  The result of applying a comparison or logical operator is always
        (0) if the result is false or (1) if the result is true.

    4)  The only valid operators to appear between character string terms
        are the comparison operators.  Character string terms may only be
        compared to other character strings of the same type.  That is,
        Ascii to Ascii, Ebcdic to Ebcdic, or Hex to Hex.  If this rule is
        not followed the results may not always be as expected.

    5)  If the two character strings being compared are not the same length
        the shorter is treated as though it were padded out to the longer length
        with blanks.  Hex strings are just compared for the shorter length.

    6)  The evaluation of any term contained within parentheses is always
        a numeric value.  If it was the result of comparison or logical
        operations, the numeric value will be (0) or (1) as indicated above.

    7)  If the value resulting from evaluating the whole body of the IF
        statement is zero (0), it is false.  If the value is not zero,
        it is true.

E.  Special comparison format.

    This format is for the purpose of selecting a record field, then
    selecting/rejecting records based on a list of values.  However, its
    implementation is more general and does not restrict it to that use.
    The format is as follows:

        item1 [operator] item2 item3 item4 ...

    The only valid operators for this format are the comparison operators.
    This expression is evaluated as though it were written as follows:

        ((item1 [oper] item2) OR (item1 [oper] item3) ...)

    Any of the items may itself be a parenthesized expression as described
    above.  There is no restriction on whether any of the items are constants
    or fields from the data record.

F.  Evaluation of multiple IF statements.

    When more than one IF statement is given, the first statement which
    evaluates as true determines the destiny of that record.  If the action
    specified for that statement is ACCEPT it is processed.  If the action
    specified for that statement is REJECT it is discarded.  The remaining
    statements are not evaluated.

    When none of the IF statements evaluate to true, the action taken is as
    follows:  If there are any statements specifying REJECT, the record is
    processed.  If there are no statements specifying REJECT (i.e. all the
    statements specify ACCEPT) the record is discarded.

    If the default action occuring when all the statements evaluate to false
    is not correct, it can easily be overriden by coding a final statement
    which is always true, such as "IF (1 = 1) action".  This would specifically
    determine the destiny of any record when all the preceeding statements
    were false.

G.  Examples.

    1.  The data records contain a 4 byte packed decimal field starting at
        position 25 in the record.  Process only the records which have values
        greater than 100 in this field.

        DEFINE count 25,4,PK
        IF (count > 100) ACCEPT

    2.  The data records are Ebcdic and in position 10 for a length of 3 bytes
        they contain a widget type.  Process only the records which have widget
        types of "010", "015", "02A", and "14B".

        DEFINE wtype 10,3,EBC
        IF (wtype = e'010' e'015' e'02A' e'14B') ACCEPT

    3.  The data records are as in (1) above.  Drop all records with values
        between 601 and 699.

        DEFINE count 25,4,PK
        IF (count GE 601 AND count LE 699) REJECT
          *note - This would evaluate correctly due to the priority levels
                  assigned to the operators.  However it could also be coded
                  as follows:
        IF ((count >= 601) & (count <= 699)) REJECT

    4.  The data records have "qty committed" a zoned decimal value at location
        58 for a length of 7.  They also have "qty available" a packed value at
        location 75 for a length of 4.  Select those records where the
        qty available is equal to or greater than twice the qty committed.
        Also select records where qty committed exceeds qty available.

        DEFINE comm 58,7,ZN
        DEFINE avail 75,4,PK
        IF (avail >= (comm * 2)) ACCEPT
        IF (comm > avail) ACCEPT

    5.  The data records have a packed decimal "price" field at location 102
        for a length of 4 and a packed decimal "quantity" field at location
        115 for a length of 5.  Select records where the total value (i.e.
        price * quantity) exceeds $5,000.

        DEFINE price 102,4,PK
        DEFINE quan 115,5,PK
        IF ((price * quan) > 500000) ACCEPT

@TESTRL

A.      This routine is for the purpose of helping to determine the
        record length of the input data.  The use of this routine is NOT
        required.  It is only for the purpose of helping find the logical
        record length when it is not known.

B.      When the routine is first entered, the data is displayed from the
        beginning of the first block of data from the file.  The left side
        of the screen shows the offset within the block followed by the hex
        representation of the data.  The right side shows the character
        representation of the data, either Ascii or Ebcdic.

C.      When the input is from tape, an asterisk (*) appears to the left
        of the length when the length value is evenly divisible into the
        block length.

Page Up/Page Down -

        Moves the display forward and backward through the block
        or record being displayed.

Up Arrow/Down Arrow -

        Like page up/page down except that it moves the display only
        one line at a time.

F2 -    Toggles the character display between Ascii and Ebcdic.

F3 -    Toggles the display mode as follows:

        1.      Allows the user to display data from the beginning of the
                input file without regard to logical records.

        2.      Shows two logical records simultaniously for comparison.
                The first line of data is from one logical record, the next
                line is from the same offset in the second logical record, etc.

        3.      Shows two logical records simultaniously for comparison.
                The top half of the screen shows data from one logical record,
                the bottom half shows the same data from the second logical
                record.

        A value must be entered in the record length field before modes
        2 or 3 may be used.

F4 -    If the input is a tape with fixed records, this routine will show
        all the values which divide evenly into the block length.  That is,
        if the records are fixed length and there is no block offset, this
        list shows the possible valid logical record lengths.

Home/End and Ctl-Home/Ctl-End

        When comparing logical records, these keys increment/decrement
        either the top or bottom logical record number being displayed.

+/- keys -

        When comparing logical records, these keys increment/decrement
        the logical record length being used by one.

