Detailed Description
2.11 Subroutine call with M, T, and D functions
Mode Group, Channel, Program Operation, Reset Response (K1)
Function Manual, 08/2005 Edition, 6FC5397-0BP10-0BA0
2-147
2.11.2 M function replacement
Subroutine call via M function
Note
Subroutine calls using an M function are referred to below as M function replacement.
The following machine data are used to configure M function replacement:
• MD10715 $MC_M_NO_FCT_CYCLE (M function to be replaced by a subroutine)
• MD10716 $MC_M_NO_FCT_CYCLE_NAME (Name of subroutine for M function)
The M function via which the subroutine specified in machine data
MD10716 $MC_M_NO_FCT_CYCLE_NAME is called is defined in machine data MD10715.
Call rules
If the M function configured with MD10715 $MC_M_NO_FCT_CYCLE is programmed in a
part program block, the appropriate subroutine is called at the end of the part program block.
If the M function is programmed again within the called subroutine, the M function is not
replaced again. In addition, other M function expansions configured with
MD10715 $MC_M_NO_FCT_CYCLE or MD10716 $MC_M_NO_FCT_CYCLE_NAME are not
executed.
Exceptions
The M function is also replaced in an ASUB if the ASUB was started in a subroutine that was
called via an M function.
Address extension of M function
Using system variable $C_ME it is possible to read the address extension of the M function
in the called subroutine.
Example configurations
• Call of subroutine SUB_M101 via M101
MD10715 $MC_M_NO_FCT_CYCLE[0] = 101
MD10716 $MC_M_NO_FCT_CYCLE_NAME[0] = "SUB_M101"
• Call of subroutine SUB_M102 through M102
MD10715 $MC_M_NO_FCT_CYCLE[1] = 102
MD10716 $MC_M_NO_FCT_CYCLE_NAME[1] = "SUB_M102"