Page 1 of 1

Goto %loop%

Posted: 13 Jan 2017 13:03
by sklub

Code: Select all

:top
set loop=:top
goto %loop%


does anyone use this ?

Re: Goto %loop%

Posted: 13 Jan 2017 13:18
by Squashman
sklub wrote:

Code: Select all

:top
set loop=:top
goto %loop%


does anyone use this ?

Why would anyone use this code?

Re: Goto %loop%

Posted: 13 Jan 2017 13:32
by sklub
not the script itself thats garbage for the garbage can.
but im looking for usefull fuction to implement a goto %loop% function...
does any one know any good use for this,because so far ive only been replacing it with real loops.

Re: Goto %loop%

Posted: 13 Jan 2017 13:48
by Cornbeetle
Not sure why you would need to do this.

Code: Select all

set label=:top

:top
set /a num+=1
echo %num%
goto %label%

Re: Goto %loop%

Posted: 13 Jan 2017 13:48
by npocmaka_
as FOR /L hangs with big numbers goto loop sometimes is the only way to use iteration loops: http://www.dostips.com/forum/viewtopic.php?t=3487

though it should be used rarely as it hits the performance.

Re: Goto %loop%

Posted: 13 Jan 2017 15:15
by Aacini
The simplest example of a similar code is this:

Code: Select all

choice /C ABC /M "Enter desired option: "
goto option-%errorlevel%

:option-1  A


:option-2  B

etc...

Antonio

Re: Goto %loop%

Posted: 14 Jan 2017 08:25
by Aspidiske
goto as variable already used as following:

This allows you to invert the sequence between programming sets

Code: Select all

@echo off
set exitprogram1=program3
set exitprogram3=program2
set exitprogram2=completed
goto program1
rem -------------------------------1
:program1
echo.1
goto %exitprogram1%
rem -------------------------------2
:program2
echo.2
goto %exitprogram2%
rem -------------------------------3
:program3
echo.3
goto %exitprogram3%
:completed
pause

Re: Goto %loop%

Posted: 15 Jan 2017 15:52
by sklub
Well im just messing around with scripts Learning in the process...Thanks for the posts