Subroutines With Parameter Transfer (Proc, Var) - Siemens SINUMERIK 840D sl Programming Manual

Job planning
Hide thumbs Also See for SINUMERIK 840D sl:
Table of Contents

Advertisement

2.3

Subroutines with parameter transfer (PROC, VAR)

2.3
Function
Program start, PROC
A subroutine that is to take over parameters from the calling program when the program runs
is designated with the keyword PROC.
Subroutine end M17, RET
The command M17 designates the end of subroutine and is also an instruction to return to
the calling main program. As an alternative to M17: The keyword RET stands for end of
subroutine without interruption of continuous path mode and without function output to the
PLC.
Programming
The parameters relevant for parameter transfer must be listed at the beginning of the
subroutine with their type and name.
Parameter transfer call-by-value
PROC PROGRAM_NAME(VARIABLE_TYPE1 VARIABLE1,VARIABLE_TYPE2
VARIABLE2,...)
Example:
PROC CONTOUR(REAL LENGTH, REAL WIDTH)
Parameter transfer call-by-reference, identification with keyword VAR
PROC PROGRAM_NAME(VAR VARIABLE_TYPE1 VARIABLE1,VAR VARIABLE_TYPE2
...,)
Example:
PROC CONTOUR(VAR REAL LENGTH, VAR REAL WIDTH)
Array transfer with call-by-reference, identification with keyword VAR
PROC PROGRAM_NAME(VAR VARIABLE_TYPE1 ARRAY_NAME1[array size],
VAR VARIABLE_TYPE2 ARRAY_NAME2[array size],
VAR VARIABLE_TYPE3 ARRAY_NAME3[array size1, array size2],
VAR VARIABLE_TYPE4 ARRAY_NAME4[ ],
VAR VARIABLE_TYPE5 ARRAY_NAME5 [,array size])
Example:
PROC PALLET (VAR INT ARRAY[,10])
Parameters
PROC
PROGRAM NAME
VARIABLE_TYPE
VARIABLE
VAR
FIELDNAME
Array size1
Array size2
Job planning
Programming Manual, 03/2006 Edition, 6FC5398-2BP10-1BA0
2.3 Subroutines with parameter transfer (PROC, VAR)
First instruction in a program
Subroutine name that should accept the relevant values of the
parameters
Variable types with specification of the variable values.
Several values can be specified.
Keyword for the type of the parameter transfer
Elements of an array with the listed values for the field
array
For a one-dimensional array
For a two-dimensional array
Subroutines, Macros
2-5

Advertisement

Table of Contents
loading

Table of Contents