Programming concepts
5.6 Variable table
S7-200 SMART
System Manual, 09/2015, A5E03822230-AC
107
To make an assignment in a variable table, follow the procedure below.
1. Ensure that the correct POU is displayed in the Program Editor window by clicking, if
necessary, on the tab of the desired POU. (Since every POU has its own variable table,
you need to make sure that you are making assignments to the correct POU.)
2. Display the variable table if it is not already visible by selecting "Variable Table" from the
Component drop-down list in the Windows area of the view menu.
3. Choose a row that has the right variable type for the kind of variable that you want to
define, and type a name for the variable in the Symbol field. If you are making an
assignment in OB1 or an interrupt routine, the variable table contains only TEMP
variables. If you are making an assignment in a subroutine, the variable table contains IN,
IN_OUT, OUT, and TEMP variables. Do not preface the name with a pound symbol in the
variable table. Pound symbols are only used to precede local variables in the program
code.
Note
Local variable names are permitted to contain a maximum of 23 alphanumeric characters
and underscores. They are also permitted to contain extended characters (ASCII 128 to
ASCII 255). The first character is restricted to alp
ha and extended characters only. It is
illegal to use keywords as symbolic names, or to use names that begin with a number or
contain characters that are not alphanumeric or in the extended character set.
Local variable names are downloaded and stored in C
PU memory. The use of longer
variable names may reduce the memory available to store your program.
4. Click the mouse pointer in the Data Type field and use the list box to select an
appropriate data type for the local variable.
Note
When you assign local variables as parameters for subroutines, you must ensure that the
data type that you assign to the local variable does not conflict with the operand being
used in the subroutine call.
5. Optionally provide a comment describing your local variable.
After you supply a value for the Symbol and Data Type fields, the Program Editor
automatically assigns an L memory address to the local variable.
Entering additional variables
The variable table displays a fixed number of rows for local variables. To add more rows to
the table, select a row in the table of the variable type that you want to add and click the
Insert button
in the variable table window. A new row is automatically generated above
the row you selected, and is for the same variable type that you selected.
You can also add rows by right-clicking an existing row and selecting
or
from the context menu.