Example: Subroutine call using string parameter
This example copies a different string literal to a unique address depending upon the given
input. The unique address of this string is saved. The string address is then passed to the
subroutine by using an indirect address. The data type of the subroutine input parameter is
string. The subroutine then moves the string to a different location.
A string literal can also be passed to the subroutine. The string reference inside the
subroutine is always the same.
LAD
MAIN
MAIN
MAIN
MAIN
SBR0
S7-200 SMART
System Manual, V2.3, 07/2017, A5E03822230-AF
Program instructions
7.18 Subroutine
STL
Network 1
LD I0.0
SCPY "string1", VB100
AENO
MOVD &VB100, VD0
Network2
LD I0.1
SCPY "string2", VB200
AENO
MOVD &VB200, VD0
Network3
LD I0.2
CALL SBR_0, *VD0
Network4
LD I0.3
CALL SBR_0, "string3"
Network 1
LD SM0.0
SSCPY *LD0, VB300
393