I unfortunately own a batch program that has duplicate label names. Can anyone explain why the GOTO goes to the label in the second block, not the first? The code:
@ECHO OFF
SET FLAG=1
IF [%FLAG%]==[1] (
ECHO IN THE FIRST IF...
GOTO TD_NEXT
:TD_NEXT
ECHO HERE AT TD_NEXT IN THE FIRST BLOCK
)
IF [%FLAG%]==[1] (
ECHO IN THE SECOND IF...
GOTO TD_NEXT
:TD_NEXT
ECHO HERE AT TD_NEXT IN THE SECOND BLOCK
)
The output:
IN THE FIRST IF...
HERE AT TD_NEXT IN THE SECOND BLOCK
I can add a third block, and see that it jumps to the one after the next, each time.
IN THE FIRST IF...
HERE AT TD_NEXT IN THE SECOND BLOCK
IN THE THIRD IF...
HERE AT TD_NEXT IN THE FIRST BLOCK
IN THE SECOND IF...
HERE AT TD_NEXT IN THE THIRD BLOCK