Programming concepts
5.6 Variable table
S7-200 SMART
124
System Manual, V2.3, 07/2017, A5E03822230-AF
Making assignments in the variable table
Note
Make the assignments in the variable table before using local variables in your program.
When you use symbolic names in your program, the program editor checks first the Local
Variable Table of the appropriate POU, and then the symbol table. If the symbolic name is
undefined in both places, the program editor treats it as an undefined global symbol which is
indicated by a green wavy underline. The program editor does not automatically re-read the
variable table and make corrections to your program logic. If you later make a data type
assignment that defines that symbolic name (in the local variable table), you must manually
insert a pound symbol (#) in front of the name, like this: #UndefinedLocalVar (in the program
logic). For this reason, declaring the variables prior to usage minimizes the programming
effort.
The maximum limit of input/output parameters for each subroutine call is 16. If you attempt to
download a program that exceeds this limit, STEP 7-Micro/WIN SMART returns an error.
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 alpha 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 CPU memory. The use of longer
variable names may reduce the memory available to store your program.