Subprogram With Call-By-Reference Parameter Transfer (Proc, Var) - Siemens SINUMERIK 840D sl Programming Manual

Nc programming
Hide thumbs Also See for SINUMERIK 840D sl:
Table of Contents

Advertisement

Work preparation
3.2 Subprogram technique
Examples
Example 1
Definition of a subprogram SUB_PROG with three parameters of type REAL with default
values:
Program code
PROC SUB_PROG(REAL LENGTH=10.0, REAL WIDTH=20.0, REAL HIGHT=30.0)
Example 2
Various call versions
Program code
PROC MAIN_PROG
REAL PAR_1 = 100
REAL PAR_2 = 200
REAL PAR_3 = 300
; Call variants
SUB_PROG
SUB_PROG(PAR_1, PAR_2, PAR_3)
SUB_PROG(PAR_1)
SUB_PROG(PAR_1, , PAR_3)
SUB_PROG( , , PAR_3)
N100 RET
See also
Subprogram call with parameter transfer (EXTERN) (Page 524)
3.2.2.3

Subprogram with call-by-reference parameter transfer (PROC, VAR)

A subprogram with call-by-reference parameter transfer is defined using the PROC keyword
followed by the name of the program and a complete list of all the parameters with the VAR
keyword, type, and name. The definition operation must appear in the first program line. As
parameters, references to arrays can also be transferred.
Call-by-reference
The calling program transfers not the value of a variable to the subprogram on a call-by-
reference parameter transfer, but a reference (pointer) to the variable. This gives the
subprogram direct access to the variable. In this way, not only the value visible in the
subprogram is modified when a parameter value is changed, but also the value of the variables
defined in the calling program. Call-by-reference parameter transfer therefore affects the
calling program, even after the subprogram has ended.
498
Programming Manual, 12/2019, 6FC5398-2EP40-0BA0
NC programming

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Sinumerik 840de sl

Table of Contents