VMS Help  —  SORT
15 MAR 1984 Living with Your Teenager 05 APR 1984 Coping with Alcoholism

14.5    /CONDITION

    Defines conditions for key and data handling and for record
    selection.

    Formats

      /CONDITION=  (NAME=condition-name,

      TEST=(field-name operator test-condition

      [logical-operator ...]))

14.5.1  –  Qualifier Values

 NAME=condition-name

    Specifies the name of the condition you are testing. This
    condition-name can be used in /KEY, /DATA, /OMIT, and /INCLUDE
    qualifiers after it has been defined using the /CONDITION
    qualifier.

 TEST=(field-name operator test-condition)

    Specifies the conditional test.

 field-name

    Specifies the name of the field you are testing. The field-name
    must be defined previously by a /FIELD qualifier.

 operator

    Specifies the logical or relational operator used in the
    conditional test. The logical operators that you can use are
    AND and OR. The relational operators that you can specify are as
    follows:

    EQ       Equal to
    NE       Not equal to
    GT       Greater than
    GE       Greater than or equal to
    LT       Less than
    LE       Less than or equal to

 test-condition

    Specifies the constant or field-name against which you are
    testing. A constant is specified with the following format:

       Decimal_digits (default)
       %Ddecimal_digits
       %Ooctal_digits
       %Xhexadecimal_digits
       "character"

                                   NOTE

       Normally, you do not need to specify the radix operator
       (%D); however, test-condition will assume the same data type
       as the field-name.

    The field-name must be defined by a /FIELD qualifier.

14.5.2  –  Full Description

    A specification file can be used to change the relative order of
    a record or to alter the contents of certain fields of a record.
    You must first use a /CONDITION qualifier to define a conditional
    test. Once you define a test using a /CONDITIONAL qualifier, you
    can use that same test with a /KEY or /DATA qualifier to change
    the order of record. You can also use the test with an /OMIT or
    /INCLUDE qualifier to change the contents of a record.

    If you want to change the order of records in the output file,
    first specify a condition name with a /CONDITION qualifier and
    set up a test for what meets that condition. Then, specify the
    relative order with a /KEY qualifier of the form:

    /KEY=(IF condition-name THEN value ELSE value)

    You can use any values to specify the relative order of the
    records.

    The /CONDITION qualifier also permits you to change the contents
    of a field in the output records. First specify a condition name,
    and then set up a test for what meets the condition. Specify the
    contents you want in the field in a /DATA qualifier of the form:

    /DATA=(IF condition-name THEN "new-contents" ELSE "new-contents")

14.5.3  –  Examples

    1./FIELD=(NAME=AGENT,POSITION:20,SIZE:15)
      /CONDITION=(NAME=AGENCY,
                  TEST=(AGENT EQ "Real-T Trust"
                  OR
                  AGENT EQ "Realty Trust"))
         /DATA=(IF AGENCY THEN "Realty Trust" ELSE AGENT)

      In this example, two real estate files are being sorted. One
      file refers to an agency as Real-T Trust; the other refers
      to the same agency as Realty Trust. The /CONDITION and /DATA
      qualifiers instruct Sort to list the AGENT field in the sorted
      output file as Realty Trust.

    2./FIELD=(NAME=ZIP,POSITION:60,SIZE:6)
      /CONDITION=(NAME=LOCATION,
                  TEST=(ZIP EQ "01863"))
      /KEY=(IF LOCATION THEN 1
            ELSE 2)

      In this example, all the records with a zip code of 01863
      will appear at the beginning of the sorted output file. The
      conditional test is on the ZIP field, defined with the /FIELD
      qualifier; the condition is named LOCATION. The values 1 and
      2 in this /KEY qualifier signify a relative order for those
      records that satisfy the condition and those that do not.

    3./FIELD=(NAME=ZIP,POSITION:60,SIZE:6)
      /CONDITION=(NAME=LOCATION,
                  TEST=(ZIP EQ "01863"))
      /DATA=(IF LOCATION THEN "NORTH CHELMSFORD"
             ELSE "Outside district")

      In this example, the /CONDITION qualifier tests for the 01863
      zip code. The /DATA qualifier specifies that the name of town
      field will be added to the output record, depending on the test
      results.

    4./FIELD=(NAME=FFLOAT,POS:1,SIZ:0,F_FLOATING)
      /CONDITION=(NAME=CFFLOAT,TEST=(FFLOAT GE 100))
      /OMIT=(CONDITION=CFFLOAT)

      In this example, the number 100 is considered to be an
      F_FLOATING data type because field FFLOAT is defined as
      F_FLOATING in the /FIELD qualifier.

14.6    /DATA

    Specifies the fields of a record to be directed to the output
    file.

    Formats

      /DATA=  field-name

      /DATA=  (IF condition-name THEN "new-contents" ELSE

              "new-contents")

14.6.1  –  Qualifier Values

 field-name

    Specifies the name of a field in a record. The field-name must be
    defined previously in a /FIELD qualifier.

 condition-name

    Specifies a condition-name that has been defined previously in a
    /CONDITION qualifier.

 new-contents

    Specifies how the record is to be altered. The new-contents can
    be a constant or a field-name that has been defined in a /FIELD
    qualifier.

14.6.2  –  Full Description

    A /DATA qualifier must identify every field in the records you
    are directing to the output file. Specify the data fields in the
    order you want them to appear in the output record. By default,
    the record format for an output file is the same as that for
    the input file. If you want to eliminate or reorder fields from
    the output record, you can use the /DATA qualifier, causing only
    those fields identified by the /DATA qualifier to be directed to
    the output file.

    You can conditionally change the contents of a field in the
    output records by first specifying a condition name and then
    setting up a test for what meets the condition in a /CONDITION
    qualifier. You then specify the contents you want in the field in
    a /DATA qualifier of the form:

    /DATA=(IF condition-name THEN "new-contents" ELSE "new-contents")

14.6.3  –  Examples

    1./FIELD=(NAME=AGENT,POSITION:1,SIZE:5)
      /FIELD=(NAME=ZIP,POSITION:6,SIZE:3)
      /FIELD=(NAME=STYLE,POSITION:10,SIZE:5)
      /FIELD=(NAME=CONDITION,POSITION:16,SIZE:9)
      /FIELD=(NAME=PRICE,POSITION:26,SIZE:5)
      /FIELD=(NAME=TAXES,POSITION:32,SIZE:5)
      /DATA=PRICE
      /DATA="  "
      /DATA=TAXES
      /DATA="  "
      /DATA=STYLE
      /DATA="  "
      /DATA=ZIP
      /DATA="  "
      /DATA=AGENT

      The /FIELD qualifiers define the fields in the records from an
      input file that has the following format:

        AGENT ZIP STYLE CONDITION PRICE TAXES

      The /DATA qualifiers, which use the field-names defined in
      the /FIELD qualifiers, reformat the records to create output
      records of the following format:

        PRICE TAXES STYLE ZIP AGENT

    2./FIELD=(NAME=AGENT,POSITION:20,SIZE:15)
      /CONDITION=(NAME=AGENCY,
                  TEST=(AGENT EQ "Real-T Trust"
                  OR
                  AGENT EQ "Realty Trust"))
         /DATA=(IF AGENCY THEN "Realty Trust" ELSE AGENT)

      In this example, two real estate files are being sorted. One
      file refers to an agency as Real-T Trust; the other refers
      to the same agency as Realty Trust. The /CONDITION and /DATA
      qualifiers instruct Sort to list the AGENT field in the sorted
      output file as Realty Trust.

14.7    /FIELD

    Specification File Qualifier

    Defines the input record fields to be used for a sort or merge
    operation or in a conditional evaluation, or whose order or
    format will change in the output record. You identify each field
    by specifying a name, its position and size in the record, and
    its data type.

    You can also use /FIELD to define a constant and assign it a
    value of any valid sort/merge data-type for use in /KEY, /DATA,
    and /CONDITION statements.

    Formats

      /FIELD=(NAME=field-name,POSITION:n,)

      SIZE:n,[DIGITS:n,]data-type

      /FIELD=(NAME=field-name,VALUE:n,)

      SIZE:n,[DIGITS:n,]data-type

14.7.1  –  Qualifier Values

 NAME=field-name

    Specifies the name of the field. The field-name cannot have any
    embedded spaces, must begin with an alphabetic character, and can
    be no longer than 31 characters.

 POSITION:n

    Specifies the position of the field in the record.

 VALUE:n

    Assigns a value to a constant field for use in a /KEY, /DATA,
    or /CONDITION statement. If you specify VALUE:n, do not specify
    /POSITION:n, because the field is a constant and not part of an
    input record.

 SIZE:n

    Specifies the size of a field containing character or binary
    data. In the specification file, SIZE implies byte lengths. The
    data type determines what values are acceptable, as well as the
    units in which the size is specified:

    o  For character data, the size must not exceed 32,767
       (characters).

    o  For binary data, the size specified must be 1, 2, 4, 8, or 16
       (bytes).

       High-performance Sort/Merge: The high-performance Sort/Merge
       utility currently supports only 1, 2, 4, and 8-byte binary
       keys.

    o  For floating-point data, no size is specified.

 DIGITS:n

    Specifies the size of a field containing decimal data. The size
    of a field containing decimal data is specified in digits. The
    size must not exceed 31 digits. Note that DIGITS:n is used only
    when describing a field containing decimal data.

 data-type

    Specifies the data type of the field. You are not required to
    specify the data-type if it is character; Sort assumes character
    data type by default. The following data types are recognized by
    OpenVMS Sort/Merge:

       CHARACTER
       BINARY[,SIGNED]
       BINARY,UNSIGNED
       D_FLOATING
       DECIMAL,LEADING_SIGN,[OVERPUNCHED_SIGN,SIGNED]
       DECIMAL,LEADING_SIGN,SEPARATE_SIGN[,SIGNED]
       DECIMAL[,SIGNED,TRAILING_SIGN,OVERPUNCHED_SIGN]
       DECIMAL,[TRAILING_SIGN],SEPARATE_SIGN[,SIGNED]
       DECIMAL,UNSIGNED
       F_FLOATING
       G_FLOATING
       H_FLOATING
       PACKED_DECIMAL
       S_FLOATING, IEEE (Alpha and I64 systems only)
       T_FLOATING, IEEE (Alpha and I64 systems only)
       PACKED_DECIMAL
       ZONED

14.7.2  –  Full Description

    Use the /FIELD qualifier to define input record fields to be used
    for a sort or merge operation or in a conditional evaluation, or
    whose order or format will change in the output record.

    Identify each field by specifying a name in the /FIELD qualifier,
    a constant value or the field position, and the size and data
    type of the field. Field names must be unique; no duplicate
    field names are allowed. You cannot use more than 255 key field
    definitions.

    Once the field-name has been specified in the /FIELD qualifier,
    it can be used in the /CONDITION, /KEY, and /DATA qualifiers.

14.7.3  –  Example

  /FIELD=(NAME=SALARY,POSITION:10,DIGITS:8,DECIMAL)

      This /FIELD qualifier identifies a field in a record by the
      name SALARY, specifies that it starts in position 10 of the
      record, is 8 digits long, and consists of decimal data.

14.8    /INCLUDE

    Specification File Qualifier

    Specifies record selection as well as multiple record formats.

    Formats

      /INCLUDE=(CONDITION=condition-name)

      [,KEY=...][,DATA=...]

14.8.1  –  Qualifier Values

 CONDITION=condition-name

    Refers to the condition-name specified in a previous /CONDITION
    qualifier.

 KEY=...

    Defines a key field because the default record type defined in
    the /KEY qualifier is not being used.

 DATA=...

    Defines a data field because the default record type defined in
    the /DATA qualifier is not being used.

14.8.2  –  Full Description

    You can specify that records are to be conditionally included
    in an output file. After defining a condition in a /CONDITION
    qualifier, specify record selection in an /INCLUDE qualifier
    requesting that records satisfying the condition are to be
    included in the output file.

    You can specify multiple /INCLUDE and /OMIT qualifiers in
    a specification file. The order in which you specify them
    determines the order the input records are tested for inclusion.
    After the last /INCLUDE qualifier, all records that have not
    already been included or explicitly omitted are omitted.

    You can unconditionally include any records not previously
    omitted or included by specifying /INCLUDE without a condition.

    When sorting multiple record formats, one /INCLUDE qualifier
    should be specified for each different record format among the
    records to be sorted. If you do not specify a KEY option within
    the INCLUDE qualifier, Sort assumes the default key definitions.
    If the KEY is specified in the /INCLUDE qualifier, the default
    key definitions are not used. The order of the KEY fields in the
    /INCLUDE qualifier determines how the internal key is built for
    sorting. The order of the DATA fields in the /INCLUDE qualifier
    determines the way the output record is formatted. If you specify
    a key or data field in an /INCLUDE qualifier, you must define all
    other key or data fields in the record.

14.8.3  –  Example

  /FIELD=(NAME=ZIP,POSITION:20,SIZE:6)
  /CONDITION=(NAME=LOCATION,
              TEST=(ZIP EQ "01863"))
  /INCLUDE=(CONDITION=LOCATION)

      These /CONDITION and /INCLUDE qualifiers specify that records
      with the zip code 01863 will be included in the output file.

14.9    /KEY

    Specification File Qualifier

    Identifies key field names, specifies sorting order, and changes
    the order of records in the output file.

    Formats

      /KEY=field-name

      /KEY=(field-name,order)

      /KEY=([IF condition-name THEN value ELSE]...value [,order])

14.9.1  –  Qualifier Values

 field-name

    Specifies the name of the key field. The field-name has been
    previously specified in a /FIELD qualifier.

 order

    Specifies the order of the sort. The ASCENDING option specifies
    ascending order for a sort or merge operation. This option is the
    default. The DESCENDING option specifies descending order for a
    sort or merge operation.

 value

    Specifies the key. The value can be a constant or a field-name
    that has been defined in a /FIELD qualifier.

14.9.2  –  Full Description

    If you are sorting on the entire record using character data, you
    do not need to specify your key field. Otherwise, specify a /KEY
    qualifier for each of the keys, in the order of their priority.
    You can sort on as many as 255 key fields.

    There are three ways to use the /KEY qualifier:

    o  To identify the key field name.

    o  To identify the key field name and to specify sorting order.
       In this case, enclose the field name and the order option in
       parentheses.

    o  As a conditional qualifier, to change the order of records
       in the output file. First, specify a condition name in a
       /CONDITION qualifier, and set up a test for what meets
       that condition. Then, specify the relative order in a /KEY
       qualifier of the form:

       /KEY=(IF condition-name THEN value ELSE value)

       You can use any values to specify the relative order of the
       records.

14.9.3  –  Examples

    1./FIELD=(NAME=SALARY,POSITION:10,DIGITS:8,DECIMAL)
      /KEY=(SALARY,DESCENDING)

      This /KEY qualifier specifies that the key field is SALARY and
      that the sorting order is descending.

    2./FIELD=(NAME=ZIP,POSITION:20,SIZE:6)
      /CONDITION=(NAME=LOCATION,
                  TEST=(ZIP EQ "01863"))
      /KEY=(IF LOCATION THEN 1
            ELSE 2)

      In this example, all the records with the zip code 01863 are
      to appear at the beginning of the sorted output file. The
      conditional test LOCATION (defined in a /CONDITION qualifier)
      is on the ZIP field (named in a /FIELD clause). The values of
      1 and 2 in this /KEY clause signify a relative order for those
      records that satisfy the condition and those that do not.

14.10    /OMIT

    Specifies that records are to be omitted from the output file
    based on a condition defined with a /CONDITION qualifier.

    Format

      /OMIT=(CONDITION=condition-name)

14.10.1  –  Qualifier Value

 CONDITION=condition-name

    Refers to the condition-name previously specified in a /CONDITION
    qualifier.

14.10.2  –  Full Description

    You can specify that records are to be omitted from the output
    file by using the /OMIT qualifier. First, you must define a
    condition with the /CONDITION qualifier. Specify your record
    selection with an /OMIT qualifier requesting the records
    satisfying that condition be selected for omission from your
    sort. By default, Sort/Merge includes all the other input records
    in the output file.

    You can specify multiple /OMIT and /INCLUDE qualifiers in your
    specification file. The order you specify them determines the
    order the input records are tested for omission. All the records
    that have not already been included or omitted after the last
    /OMIT qualifier are included. You can unconditionally omit any
    records not previously omitted or included by specifying the
    /OMIT qualifier only.

14.10.3  –  Example

  /FIELD=(NAME=ZIP,POSITION:20,SIZE:6)
  /CONDITION=(NAME=LOCATION,
              TEST=(ZIP EQ "01863"))
  /OMIT=(CONDITION=LOCATION)

      These /CONDITION and /OMIT qualifiers specify that records with
      the zip code 01863 are to be omitted from your output file.

14.11    /PAD

    Allows you to specify a pad character to use when reformatting
    records or when comparing strings of unequal length.

    Format

      /PAD=single-character

14.11.1  –  Qualifier Value

 single-character

    Specifies the character that the Sort utiltiy will use to pad a
    string. Characters, decimal, octal, or hexadecimal digits can be
    used. The pad character should be specified as follows:

    o  Use quotation marks for a character. For example, " # " would
       specify the number sign.

    o  Use decimal radix for decimal digits. For example, %D35 would
       specify the decimal number 35.

    o  Use octal radix for octal digits. For example, %O043 would
       specify the octal number 043.

    o  Use hexadecimal radix for hexadecimal digits. For example,
       %X23 would specify the hexadecimal number 23.

14.11.2  –  Full Description

    Use the /PAD qualifier to specify a pad character when comparing
    strings of unequal length or when reformatting records. By
    default, Sort uses the null character for padding, ensuring
    conformity with the previous versions. Double characters that
    can be defined as single characters ("ch" > "c") cannot be used
    as pad characters.

14.11.3  –  Example

  /PAD="."

      This example of a /PAD qualifier specifies that records will be
      padded with periods.

14.12    /PROCESS

    Defines the processing method (record, tag, address, or index)
    for the sorting operation. Use only with the SORT command.

    Format

      /PROCESS=type

14.12.1  –  Qualifier Values

 RECORD

    Specifies the record sort. This sort process is the default.

 TAG

    Specifies the tag sort.

 ADDRESS

    Specifies the address sort.

 INDEX

    Specifies the index sort.

14.12.2  –  Full Description

    By default, Sort uses a record sorting process. You can also
    specify a tag, address, or index sorting process. If you intend
    to reformat the output records, you cannot use address or index
    sort. For a comparison of the four processes, see the description
    of /PROCESS in the Command Qualifiers Section. Use the /PROCESS
    qualifier with the SORT command only.

14.12.3  –  Example

  /PROCESS=tag

      This example of the /PROCESS qualifier specifies that Sort use
      a tag sorting process.

14.13    /STABLE

    Specifies that records with equal keys are directed to the
    output file in their input file order. The default condition
    is /NOSTABLE.

    Formats

      /STABLE

      /NOSTABLE

14.13.1  –  Full Description

    By default, when records are sorted with identical keys, the
    order of those records in the output file may not be the same as
    they appeared in the input file. Specifying the /STABLE qualifier
    in a specification file arranges records with equal keys in the
    output file in the order of the input files as specified in the
    command line. If you use this qualifier when sorting multiple
    input files, on output, records with equal keys in the first file
    will precede those from the second file and so on.

14.13.2  –  Example

  /STABLE

      This example of the /STABLE qualifier ensures that records with
      equal keys will have the same order in the input and output
      files.

14.14    /WORK_FILES

    Reassigns work files to different disk-structured devices to
    improve performance. Use only with the SORT command.

    Format

      /WORK_FILES=(device[,...])

14.14.1  –  Qualifier Value

 device

    Specifies a logical name for the work file. Unlike the DCL
    qualifier /WORK_FILES=n, the specification file qualifier /WORK_
    FILES=(device[,...]) specifies work file assignments, not the
    number of work files.

14.14.2  –  Full Description

    You can improve the performance of Sort by placing work files
    on different disk-structured devices. Using the /WORK_FILES
    qualifier in a specification file to reassign work files makes
    it unnecessary to make logical assignments prior to invoking Sort
    at the command or program level.

14.14.3  –  Example

  /WORK_FILES=("WRKD$:")

      This example of a /WORK_FILES qualifier assigns one of Sort's
      work files to the device WRKD$: because that device has the
      most space available.
Close Help