Siemens Industry Online Support
Siemens AG
Entry type: Application example Entry ID: 5669592, Entry date: 11/06/2000

How do you access local data of a previous function?

  • Entry
  • Associated product(s)
If you access previous local data (V-L data), you can transfer a self-constructed ANY pointer or the absolute address on the calling FC.

If you transfer a self-constructed ANY pointer, the area pointer would point to its own local data, which does not make any sense. Therefore it is absolutely necessary that the ID for the V area be in the ANY pointer. This ID must be transferred explicitly. When you specify the absolute address, the compiler does this task.

General program structure
Transfer as ANY pointer or absolute:

LAR1 P##target


// Initial address of the locally defined ANY variable
L W#16#87// Load ID for the V area
T LB[AR1, P#6.0]// Transfer into an ANY variable
source1: = #target// Transfer of the self-constructed ANY pointer
source2: = P#L0.0 BYTE 8//Transfer of the absolute L data area

Differences between the absolute addressing and the addressing via an ANY pointer
The following figure shows the difference between the absolute addressing and the addressing via a self-constructed ANY pointer. In this case the ID "87" was not transferred, which is why the ANY pointer is pointing to its own local area.

Further Information
More information about the structure of the ANY pointer is available in the STEP 7 Online Help under

  • Format of the ANY parameter type
  • Parameter types
  • Using the ANY parameter type

The example demonstrates the behavior in the cases of incorrect and correct transfer of the ANY pointer. Based on a variables table (VAT) you can preset the local variables of both functions. Furthermore, you can make a preselection in the table as to whether the ID of the V area is to be transferred or not.

VAT parameter

Operand Comment
M 240.0

Preset: 0 = Access to V-L data, 1 = Access to L data

MD 200

Presetting of V-L data (FC22)

MW 204

Presetting of V-L data (FC22)

M 206

Presetting of V-L data (FC22)

MD 210

Presetting of L data (FC23)

MW 214

Presetting of L data (FC23)

MW 216

Presetting of L data (FC23)

MD 230

Current values (L or V-L data)

MD 234

Current values (L or V-L data)

MD 236

Current values (L or V-L data)

The following download includes a STEP 7 V5.5 project with the two functions described. The variables table is for presetting or monitoring the function. In this example we show the principle behavior. You can change this project to suit your requirements.

 Registration required  5669592_AnyFC_Proj_STEP7.zip (1.1 MB) 
SHA256: 671AB8A7871C59AE3271C0A42C2AB13BD775A243A8DF26F1093BBF4721EFE3C3

Unpack the file "5669592_AnyFC_Proj_STEP7.zip" into a separate directory. The STEP 7 V5 project is unpacked automatically with all the associated subdirectories. You can then use the SIMATIC Manager to open and process the extracted project.

Security information
In order to protect technical infrastructures, systems, machines and networks against cyber threats, it is necessary to implement – and continuously maintain – a holistic, state-of-the-art IT security concept. Siemens’ products and solutions constitute one element of such a concept. For more information about cyber security, please visit
Requests and feedback
What do you want to do?
Note: The feedback always relates to the current entry / product. Your message will be forwarded to our technical editors working in the Online Support. In a few days, you will receive a response if your feedback requires one. If we have no further questions, you will not hear from us.