GOTO


Type: Internal (2.0 and later)

Syntax:

GOTO (label)

Purpose: Causes unconditional branch to the specified label.

Discussion

Sends the program to the command found in the line immediately after the label definition.

A label is the first eight characters on a batch file line after a colon. The label can be indented, as long as there are only spaces preceding it on that line. The label (the string of eight characters) can include spaces but not other restricted characters such as commas, semicolons, or equal signs.

A label name after a GOTO command transfers processing to the line containing the label. If a label is not found (or if the label contains illegal characters), an error message is displayed and the batch file terminates.
For more information on using the GOTO command and other batch commands, refer to Chapter 5, Using Batch Files.


Example

To create a batch file that will function as an infinite loop displaying the message This is an infinite loop, enter

:START
echo This is an infinite loop goto START
A number of more useful
Examples
using the GOTO command can be found in this chapter.


Back to the Easy DOS Command Index