Programming concepts
5.6 Variable table
S7-200 SMART
System Manual, V2.3, 07/2017, A5E03822230-AF
121
Sorting a symbol table
You can sort a symbol table by the Symbol or by the Address column in either ascending or
descending alphabetical order. In the Address column, numeric constants sort above string
constants, which sort above addresses.
To sort a column, click either the Symbol or Address column header to sort by that value. To
reverse the order of the sort, click the column again. STEP 7-Micro/WIN SMART displays an
up or down arrow next to the column that is sorted to indicate the sort selection.
Note
You can print symbol tables from the Print area of the File menu ribbon strip.
You can view symbols on a network-by-network basis by displaying the symbol information
table.
5.6
Variable table
A variable table allows you to define variables that are local to a specific POU. The following
situations define when to use a local variable:
●
You want to create portable subroutines that do not make references to absolute
addresses or global symbols.
●
You want to use interim variables (local variables declared as TEMP) to perform
calculations in order to free up PLC memory.
●
You want to define inputs and outputs for your subroutines.
If these descriptions do not fit your situation, you do not need to use local variables; you can
make all of your symbolic values global by defining them in the symbol table (Page 118).
Understanding local variables
You can use the variable table of the program editor to assign variables that are unique to an
individual subroutine or interrupt routine.
Local variables can be used as parameters that are passed in to a subroutine and can be
used to increase the portability or reuse of a subroutine.
Each POU (Page 105) in your program has its own variable table, with 64 bytes of L memory
(60 bytes if you are programming in LAD or FBD). These local variable tables allow you to
define variables that are restricted in scope: a local variable is only valid inside the POU
where it was created. By contrast, global symbols, which are valid in every POU, can only be
defined in the symbol table. In cases where you use the same symbolic name (e.g., INPUT1)
for a global symbol and a local variable, the local definition takes precedence inside the POU
where the local variable has been defined and the global definition is used in the other
POUs.