6 Programming
6-58
NJ-series CPU Unit Software User’s Manual (W501)
Variables for Which You Can Specify the Retain Attribute
AT specifications are made separately for each variable. Set them for all elements and members of
array, structure, and union variables.
The variable is set to the initial value in the following situations.
• When power is turned ON
• When changing between RUN mode and PROGRAM mode
• When you select the Clear the present value of variables with Retain attribute Check Box, and down-
load the user program
• When a major fault level Controller error occurs
You can set an initial value for a variable in advance so that you do not have to write a program to initial-
ize all of the variables. For example, you can preset data such as a recipe as initial values. You do not
have to set any initial values.
Types of Variables That Can Have Initial Values
You can set initial values for only some types of variables. A list is provided below.
Enabling an Initial Value
You can specify whether a variable has an initial value when you create the variable.
The following table shows the variables for which you can set an initial value.
Initial Value
Type of variable Initial Value
Global variables Supported.
Internal variables
Input variables
Output variables
Return values of functions Not supported.
In-out variables
External variables
Type Example Enabling an Initial Value
Basic data type variables aaa Supported.
Array variables
Arrays bbb Supported.
Elements bbb[2] Not supported.
Structure variables
Structures ddd Supported.
Members ddd.xxx Not supported.
Union variables
Unions eee Not supported (initial values are always 0).
Members eee.word Initial values are always 0.
Enumerated variables ccc Supported.
POU instances instance Not supported.
No Initial Value Specified
Initial value
None
Initial Value Specified
Initial value
Initial value
3.14 (Blank)
Or