gosub( sectionname )
Parameters
| Type | Description | |
| sectionname | section | name of a section |
_result
Not set.
Descriptions
The gosub statement is not actually a robot command, but rather a way to control which robot instructions are run. Gosub causes execution to jump to the first line of the section specified by the sectionname parameter. When the called section completes, execution returns to the line following the gosub call.
Gosub is used as a means of organizing the
instructions within a robot. Robot instructions that are related and used often
can be placed in a section then called from any number of locations with the
gosub command.
Sections that are executed with a gosub command inherit the priority of their callers.
This means sections called with the gosub command have no affect on events. If
a higher priority even occurs, a section called with gosub will be preempted by
the higher priority handler as expected.
Sections are not able to return values, so gosub does not modify the _result variable. The gosub command may be used to call a section recursively, but there is a limit of 2,000 nested gosub calls.
The _stack and _line system variables are very helpful when following the execution path of a robot's code.
See Also