0

Well, I have this problem with a little program that I'm making because my loop is endless. Right now I'm trying to use goto command but it doesn't work couse it is endless. Anyone please help.

@echo off
color 1a
:i
echo Hi, mate Let's start off by getting each others names.
timeout 5 > nul
echo What is your name ?: 
set /p name=
echo Hi noob %name% my name is Youke 
timeout 2 > nul
echo %name% We are going on an advenutre quest today :D
timeout 2 > nul
goto i
famousgarkin
  • 13,687
  • 5
  • 58
  • 74
Youke
  • 13
  • 4
  • What's the code intention? What is the goto purpose? – Mephy May 15 '14 at 17:06
  • The purpose of the goto is actually nothing it's something i wan't to try out on my programming skills in notepad. – Youke May 15 '14 at 17:09
  • 2
    If it has no purpose, why is it there? Your code loops endlessly because you *told* it to with the `goto`. – Andrew May 15 '14 at 17:10
  • `goto` means " go to " ... – Stephan May 15 '14 at 17:21
  • I'm using this little program as my testing program to test all my new stuff i only want to know how to add a loop that isn't endless. – Youke May 15 '14 at 17:24
  • 2
    then why don't you ask so? `for /L` is your friend. Or if you want to do it "the hard way", use a counter and jump with `if %count% lss 15 goto ...` – Stephan May 15 '14 at 17:38

1 Answers1

1

Somewhere between the i label on line 3 and the goto command, you need to add code that will break out of the loop—likely an if statement with another goto inside it that points to a label after your current goto.

You can see plenty of examples here: https://stackoverflow.com/a/4711984/436282

Community
  • 1
  • 1
Andrew
  • 4,953
  • 15
  • 40
  • 58