Initial-Value Definition

#### Search Results

Search

# Initial-Value Definition

|  |  | `FULL LENGTH` `LENGTH` n |  | `<`character-string`>` |
`<` |  | constant system-variable |  | `>`

For an explanation of the symbols used in the syntax diagram, see Syntax Symbols.

The `init-definition` option is used to define the initial/constant values for a variable.

Note
If, in the `variable-definition` option, the keyword `INIT` was used for the initialization, the value may be modified by any statement that affects the content of a variable. If the keyword `CONST` was used for the initialization, any attempt to change the value will be rejected by the compiler.

See also Field Definitions, Initial Values in the Programming Guide.

This document covers the following topics:

- Restrictions with Initial-Value Definition

- Syntax Description of Initial-Value Definition

## Restrictions with Initial-Value Definition

For a redefined field, an `init-definition` is not permitted.

## Syntax Description of Initial-Value Definition

Syntax Element | Description
--- | ---
`<constant>` | Constant Value Option: The constant value with which the variable is to be initialized; or the constant value to be assigned to the field. For further information, see User-Defined Constants in the Programming Guide.
`<system-variable>` | System Variable Option: The initial value for a variable may also be the value of a Natural system variable, for example:
    DEFINE DATA LOCAL
    1 #MYDATE (D) INIT <*DATX>
    END-DEFINE
Note When the variable is referenced in a `RESET INITIAL` statement, the system variable is evaluated again; that is, it will be reset not to the value it contained when program execution started but to the value it contains when the `RESET INITIAL` statement is executed.
`FULL LENGTH <character-string>` `LENGTH n <character-string>` | Character String Option for Alphanumeric/Unicode Variables: For a variable of the Natural data format A or U, a `character-string` (for example, `'ABC'`) can be used as an initial value which fills all or part of the variable field. A `character-string` is a constant of the Natural data format A or U as described in Alphanumeric Constants and Unicode Constants in the Programming Guide. FULL LENGTH Option: With the `FULL LENGTH` option, a particular `character-string` is repeatedly moved to the specified field until the field is completely filled. In the following example, the entire field is filled with asterisks:
    DEFINE DATA LOCAL
    1 #FIELD (A25) INIT FULL LENGTH <'*'>
    END-DEFINE
LENGTH Option: With the `LENGTH n` option, a particular `character-string` is repeatedly moved to the specified field until the first `n` positions of the field are filled. `n` must be a numeric constant. In the following example, the first four positions of the field are filled with exclamation marks:
    DEFINE DATA LOCAL
    1 #FIELD (A25) INIT LENGTH 4 <'!'>
    END-DEFINE

### On this page

- Restrictions with Initial-Value Definition
- Syntax Description of Initial-Value Definition