GOTO--Examples
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.
Discovered August 20, 2001.
@ECHO OFF
GOTO BEGIN
:LABEL(1)
ECHO. This is :LABEL(1)
GOTO LABEL(2)
:BEGIN
ECHO. This is label :BEGIN [+ SPACE] + Character of ASCII value 26
GOTO LABEL(1)
:LABEL(2)
ECHO. This is :LABEL(2)
The character of ASCII value 26 (1Ah), a.k.a. End Of File, (EOF),
won't be found as/when one could expect it to be found.
DOS displays something like this:
This is label :BEGIN [+ SPACE] + Character of ASCII value 26
This is :LABEL(1)
Label not found
Note: It is not possible to disable such a character as the character
of ASCII value 26 (1A hex) with a prefix of double colons (::).
Related link: Self deleting batch file and based on the character 1Ah.
|