Technical data

Appendix
27.3 Data Types and Parameter Types
Programming with STEP 7
Manual, 05/2010, A5E02789666-01 613
27.3.4.4 Block for Changing the Pointer
Using the sample block FC3 "Routing Pointers" it is possible to change the bit or byte address of a
pointer. The pointer to be changed is transferred to the variable "pointer" when the FC is called
(area-internal and area-crossing pointers in double word format can be used).
With the parameter "Bit-Byte" you can change the bit or byte address of the pointer (0: bit address,
1: byte address). The variable "Inc_Value" (in integer format) specifies the number that should be
added to or subtracted from the address contents. You can also specify negative numbers to
decrement the address.
With a bit address change, there is a carry over to the byte address (also when decrementing), for
example:
P#M 5.3, Bit_Byte = 0, Inc_Value = 6 => P#M 6.1 or
P#M 5.3, Bit_Byte = 0, Inc_Value = -6 => P#M 4.5.
The area information of the pointer is not influenced by the function.
The FC intercepts an overflow/underflow of the pointer. In this case the pointer is not changed and
the output variable "RET_VAL" (error handling possible) is set to "1" (until the next correct
processing of FC3). This is the case where:
1. Bit address is selected and Inc_Value >7, or <-7
2. Bit or byte address is selected and the change would result in a "negative" byte address
3. Bit or byte address is selected and the change would result in an illegally large byte address.
Sample Block in STL to Change the Pointer
FUNCTION FC 3: BOOL
TITLE =Routing Pointers
//FC3 can be used to change pointers.
AUTHOR : AUT1CS1
FAMILY : INDADDR
NAME : ADDRPOINT
VERSION : 0.0
VAR_INPUT
Bit_Byte : BOOL ; //0: Bit address, 1: byte address
Inc_Value : INT ; //Increment (if value neg. => decrement/if value pos. => increment)
END_VAR
VAR_IN_OUT
Pointer : DWORD ; //Pointer to be changed
END_VAR
VAR_TEMP
Inc_Value1 : INT ; //Interim value increment
Pointer1 : DWORD ; //Interim value pointer