beautypg.com

Local variables in user program steps, Ee local variables in expressions, Local variables in expressions – Delta RMC151 User Manual

Page 347: Local variables, Ee local variables, Local variable

background image

5 Programming

Type your expression. The intellisense will offer suggestions for variables and

tag names based on what you have typed.

If the expression is invalid, the portion in error will be red.

3. Press Enter to finish editing. If the expression is invalid, the entire expression text will

be red. When the entire expression is in black text, the expression is valid.


5.13.5. Local Variables in User Program Steps

Local variables can be declared in user programs steps. Variables declared in this way can only

be accessed within that step. The variable values are valid only for the execution of that step.

When the task jumps to another step, the local variable values are not retained, even if the

task jumps to the same step.
Local variables are different from variables in the variable table. For complex programs, local

variables may significantly reduce the number of variables needed in the variable table.

Adding Local Variables to a Step

To add local variables to a user program step:

1. On the toolbar, click the Add Step Declarations button. Or, right-click the step

and choose Add Step Declarations.

2. A Declarations section will appear.
3. Declare your variable between the VAR and END_VAR keywords, as shown in the

example below.

Variables can be of REAL, DINT, or DWORD data types, and can be also be fixed-

length arrays. Variables can optionally be initialized to a value upon declaration.

Variables that are not initialized when declared will default to the value 0.

Example:

Usage

Local variables in a user program step can be used in Expression (113) commands, in

command parameters, and in link conditions.

Arrays

Bounds
The lower and upper array bounds are given in brackets. For example, bounds of [0..6]

declare an array of 7 items. The upper and lower bounds of the array can be any value,

including negative values. For most applications, the lower bound will be zero.
Initializing

deltamotion.com

327

This manual is related to the following products: