CDDLHELP.HLB  —  INITIAL_VALUE
  The INITIAL_VALUE field attribute clause  declares  a  field's  value
  when CDDL first allocates the field.

1  –  Usage Notes

   o  The value of the literal must fit into the  space  allocated  for
      the field.

   o  You can specify a complex number as the INITIAL_VALUE only  of  a
      field  whose data type is F_FLOATING COMPLEX, D_FLOATING COMPLEX,
      G_FLOATING COMPLEX, or H_FLOATING COMPLEX.

   o  You can specify a fixed point number as the INITIAL_VALUE of  any
      field  whose  data  type  is not DATE, TEXT, UNSPECIFIED, VARYING
      STRING, or VIRTUAL FIELD.

   o  You can specify a floating point number as the INITIAL_VALUE of a
      field  whose  data  type  is not DATE, TEXT, UNSPECIFIED, VARYING
      STRING, or VIRTUAL FIELD.

   o  You can specify a quoted string as the INITIAL_VALUE  only  of  a
      field  whose  data  type  is  DATE, TEXT, UNSPECIFIED, or VARYING
      STRING.

   o  The quoted-string in the EXTERNAL subclause contains a legal  VAX
      COBOL external name.

   o  You can use 8-bit characters in CDDL quoted strings.

   o  You can specify a hexadecimal number as the  INITIAL_VALUE  of  a
      field  with  any  data  type  except  VIRTUAL FIELD.  In order to
      specify a hexadecimal number, place single  quotation  marks  (')
      around the number and precede it with %X; for example,

      INITIAL_VALUE IS %X'3E'

   o  You can specify an octal number as the INITIAL_VALUE of  a  field
      with  any data type except VIRTUAL FIELD.  In order to specify an
      octal number, place single quotation marks (') around the  number
      and precede it with %O; for example,

      INITIAL_VALUE IS %O'16'

   o  A VIRTUAL FIELD cannot have an INITIAL_VALUE clause.

   o  Language processors that do not support the INITIAL_VALUE  clause
      ignore it.

   o  If the base is not ten and scale is not  zero,  you  can  specify
      initial values only in hexadecimal or octal.  Furthermore, before
      you translate the initial value  to  hexadecimal  or  octal,  you
      should multiply it by the base raised to the value of the scale.

      For example, to specify an initial value of 1 for  a  field  with
      base  2  and scale 5, first multiply the value by 2 raised to the
      fifth, yielding 32.  Then convert 32 to its hexadecimal or  octal
      equivalent, and store that value.

2  –  Example

  The  following  data  declaration   gives   the   field   AMOUNT   an
  INITIAL_VALUE of 0.

  TRANSACTION STRUCTURE     OCCURS 1 TO 99 TIMES
                            DEPENDING ON TRANSACTION_COUNT.
      TRANS_DATE            DATATYPE IS DATE.
      ORDER_NUMBER          DATATYPE IS UNSIGNED NUMERIC
                            SIZE IS 10 DIGITS.
      AMOUNT                DATATYPE IS UNSIGNED NUMERIC
                            SIZE IS 8 DIGITS 2 FRACTIONS
                            INITIAL_VALUE IS 0.
  END TRANSACTION STRUCTURE.
Close Help