The GOTO command is commonly used to skip over subroutines or blocks of code and transfer control to another location in the program. Observe the following guidelines when using a GOTO command:

  • Make sure GOTO commands are routing control to a program line and not a comment line.
  • Except for the last line of the program, all GOTO commands must transfer control to the same or a sequentially higher line number.
  • The GOTO command in the last line of the program is the only command that transfers control to the top of the program.
  • If no other program lines need to be read during a pass, transfer program control to the GOTO command in the last line of the program.
  • Use GOSUB and RETURN to transfer program control to and from subroutines. Do not use the GOTO command.