Bosch 6000 User's Guide Page 38

  • Download
  • Add to my manuals
  • Print
  • Page
    / 268
  • Table of contents
  • TROUBLESHOOTING
  • BOOKMARKS
  • Rated. / 5. Based on customer reviews
Page view 37
Chapter 1. Programming Fundamentals
23
Program Flow Control
Program flow refers to the order in which commands will be executed, and whether they will
be executed at all. In general, commands are executed in the order in which they are received.
However, certain commands can redirect the order in which commands will be processed.
You can affect program flow with:
Unconditional Loops and Branches
Conditional Loops and Branches
Unconditional Looping and Branching
Unconditional
Looping
The Loop (L) command is an unconditional looping command. You may use this command
to repeat the execution of a group of commands for a predetermined number of iterations. You
can nest Loop commands up to 16 levels deep. The code sample (portion of a program) below
demonstrates a loop of 5 iterations.
MA0 ; Sets unit to Incremental mode
A50 ; Sets acceleration to 50
V5 ; Sets velocity to 5
L5 ; Loops 5 times
D2000 ; Sets distance to 2,000
GO1 ; Executes the move (Go)
T2 ; Delays 2 seconds after the move
LN ; Ends loop
Unconditional
Branching
There are three ways to branch unconditionally:
GOTO: The GOTO command transfers control from the current program being processed to
the program name or label stated in the GOTO command.
GOSUB: The GOSUB command branches to the program name or label stated in the GOSUB
command; however, the GOSUB command returns control to the program where the
branch occurred (resumes at the next command line after the GOSUB).
JUMP: The JUMP command branches to the program name or label stated in the JUMP
command. All nested IFs, WHILEs, and REPEATs, loops, and subroutines are
cleared; thus, the program or label that the JUMP initiates will not return control to
the line after the JUMP, when the program completes operation. Instead, the
program will end.
If an invalid program or label name is entered, the branch command will be ignored and
processing will continue with the next line in the program.
The 6000 family does not support recursive calling of subroutines.
Using labels: Labels, defined with the $ command, provide a method of branching to specific
locations within the same program. Labels can only be defined within a program and executed
with a GOTO, GOSUB, or JUMP command from within the same program (see Example B below).
NOTE
Be careful about performing a GOTO within a loop or branch statement area (i.e., between
L & LN, between IF & NIF, between REPEAT & UNTIL, or between WHILE & NWHILE). Branching
to a different location within the same program will cause the next L, IF, REPEAT, or WHILE
statement encountered to be nested within the previous L, IF, REPEAT, or WHILE statement
area, unless an LN, NIF, UNTIL, or NWHILE command has already been encountered.
** To avoid this nesting situation, use the JUMP command instead of the GOTO command.
Page view 37
1 2 ... 33 34 35 36 37 38 39 40 41 42 43 ... 267 268

Comments to this Manuals

No comments