Library /sys$common/syshlp/CDDLHELP.HLB  —  VARIANTS field
  Defines two or more logical views of the same  portion  of  a  record
  definition.   The  VARIANTS  statement  functions  like the REDEFINES
  clause in VAX COBOL and VAX DATATRIEVE.

1  –  Parameter

  variant

       A definition of the field characteristics for  each  subordinate
       field of each VARIANT.

2  –  Syntax Rule

  The VARIANTS, VARIANT, and END statements all must end with periods.

3  –  Usage Notes

   o  Each VARIANT begins on the same byte in the  record,  subject  to
      individual  alignment options.  The length of the longest VARIANT
      in the collection determines the overall length of  the  VARIANTS
      field description.

   o  Be sure that the VARIANTS collection you define conforms  to  the
      requirements  of  the  language  or  language processor that will
      access the record definition.

   o  VAX DATATRIEVE requires each VARIANT to contain a STRUCTURE field
      description statement at the top of the VARIANT.

4  –  Example

  The following example contains three VARIANT  logical  views  of  the
  same record.  In an application program, you can refer to the logical
  view IN_STOCK, BACK_ORDER, or OUT_OF_STOCK depending on how you  want
  to interpret the STOCK field.

  STOCK STRUCTURE.
      VARIANTS.
          VARIANT.
              IN_STOCK STRUCTURE.
                  PRODUCT_NO     DATATYPE IS TEXT
                                 SIZE IS 8 CHARACTERS.
                  DATE_ORDERED   DATATYPE IS DATE.
                  STATUS_CODE    DATATYPE IS BYTE.
                  QUANTITY       DATATYPE IS LONGWORD
                                 ALIGNED ON LONGWORD.
                  LOCATION       ARRAY 1:4
                                 DATATYPE IS TEXT
                                 SIZE IS 30 CHARACTERS.
                  UNIT_PRICE     DATATYPE IS LONGWORD SCALE -2.
              END IN_STOCK STRUCTURE.
          END VARIANT.
          VARIANT.
              BACK_ORDER STRUCTURE.
                  PRODUCT_NO     DATATYPE IS TEXT
                                 SIZE IS 8 CHARACTERS.
                  DATE_ORDERED   DATATYPE IS DATE.
                  STATUS_CODE    DATATYPE IS BYTE.
                  QUANTITY       DATATYPE IS LONGWORD
                                 ALIGNED ON LONGWORD.
                  SUPPLIER       ARRAY 1:4
                                 DATATYPE IS TEXT
                                 SIZE IS 30 CHARACTERS.
                  UNIT_PRICE     DATATYPE IS LONGWORD
                                 SCALE -2.
              END BACK_ORDER STRUCTURE.
          END VARIANT.
          VARIANT.
              OUT_OF_STOCK STRUCTURE.
                  PRODUCT_NO         DATATYPE IS TEXT
                                     SIZE IS 8 CHARACTERS.
                  DATE_LAST_SOLD     DATATYPE IS DATE.
              END OUT_OF_STOCK STRUCTURE.
          END VARIANT.
      END VARIANTS.
  END STOCK STRUCTURE.
Close Help