Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought


 goto(CMD)                       19 June 1992                       goto(CMD)


 Name

    goto - direct MS-DOS to a line in a batch program marked by a specified
    label

 Syntax


    goto label


 Description

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

 Parameter


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


 Notes


    Valid values for label

    The label parameter can include spaces but cannot include other separa-
    tors, such as 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. There-
    fore, 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 begin with
    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 per-
    form conditional operations.  For more information about using goto for
    conditional operations, see the if(CMD) command.

 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 End of batch program.


Typewritten Software • bear@typewritten.org • Edmonds, WA 98026