------------------------- MS-DOS v6.22 Help: Goto --------------------------
<Notes> <Examples>                                               <Index>
----------------------------------------------------------------------------

                                    GOTO

Directs MS-DOS to a line in a batch program that is marked by a label you
specify. You can use this command only in batch programs.

The GOTO command directs MS-DOS within a batch program to a line identified
by a label. When MS-DOS finds the label, it processes the commands beginning
on the next line.

Syntax

    GOTO label

Parameters

label
    Specifies the line in a batch program to which MS-DOS should go.

                                      ***

<Syntax> <Examples>
----------------------------------------------------------------------------

                                GOTO--Notes

Valid values for label

The label parameter cannot include separators such as spaces, semicolons or
equal signs.

GOTO uses the first eight characters of each label

The GOTO command uses only the first eight characters of a label. Therefore,
the labels "hithere01" and "hithere02" are both equivalent to "hithere0".

Matching the label parameter with the label in the batch program

The label value you specify on the GOTO command line must match a label in
the batch program. The label within the batch program must be preceded by a
colon.

If your batch program does not contain the label that you specify, the batch
program stops and MS-DOS displays the following message:

    Label not found

MS-DOS recognizes a batch-program line beginning with a colon (:) as a label
and does not process it as a command. If a line begins with a colon, MS-DOS
ignores any commands on that line.

Using GOTO for conditional operations

GOTO is often used on the same command line with other commands to perform
conditional operations. For more information about using GOTO for
conditional operations, see the <IF> command.

                                      ***

<Syntax> <Notes>
----------------------------------------------------------------------------

                               GOTO--Example

The following batch program formats a disk in drive A as a system disk. If
the operation is successful, the GOTO command directs MS-DOS to a label
named "end".

    echo off
    format a: /s
    if not errorlevel 1 goto end
    echo An error occurred during formatting.
    :end
    echo Successfully formatted the disk in drive A.

                                      ***

----------------------------------------------------------------------------
<Top of page>
Last update: December 07, 2002 14:45 by
Content © 1997 Microsoft Corporation
All else © 2000-2005
Counter