Gosub Return ( Branches To A Subroutine ) - Mitsubishi QD51 Programming Manual

Logic controller
Hide thumbs Also See for QD51:
Table of Contents

Advertisement

11 INSTRUCTIONS AND FUNCTIONS
GOSUB RETURN
• Branches to a subroutine and returns to the specified line number.
GOSUB
Syntax
RETURN
line number 1
line number 2
GOSUB 100
Examples
• The GOSUB to RETURN instruction branches to the subroutine by GOSUB, then returns
Description
to the instruction after the GOSUB instruction, specified line number, or label by the
RETURN instruction.
• <line number> can also be specified by a label.
• The same subroutine can be called many times in a program.
• Subroutines can be nested as long as the memory capacity allows.
An "Out of Memory" error occurs when the memory runs out.
• The RETURN instruction returns the control to the following instruction of the GOSUB
instruction that branched to the subroutine.
• While multiple RETURN instructions can be specified within one subroutine, they have to
correspond to GOSUB instructions correctly.
• A subroutine must be used by a GOSUB instruction. If it is executed by itself, a "RETURN
without GOSUB" error occurs when the RETURN instruction is executed.
11 - 80
Instruction
GO to SUBroutine/RETURN
<line number 1>
[ <line number 2> ]
• • • •
• • • •
• • • •
10
GOSUB1000
500
Specify the starting line number of the subroutine to
be branched.
Specify the line number to return.
Branches to the subroutine of line number 100.
1000
2000
GOSUB2000
2500RETURN
1500RETURN
MELSEC-Q
11 - 80

Advertisement

Table of Contents
loading

This manual is also suitable for:

Ad51h-s3Qd51-r24A1sd51s

Table of Contents