MS DOS For Loop

  • Tdotwire
  • Proficient
  • Proficient
  • User avatar
  • Posts: 486
  • Loc: Toronto

Post 3+ Months Ago

Does nayone know how to execute a for loop command in DOS?

Is there any way to make it act as if it was that of a while loop...

for example

while(true) //runs an infinite loop

can you do that with MSDOS?
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • Super Moderator
  • Super Moderator
  • User avatar
  • Posts: 23456
  • Loc: Woodbridge VA

Post 3+ Months Ago

You use For In Do

You can use the For command to repeat a single command, executing it once for each member of a list or group of files. Unlike most other batch commands, For can be very useful both from the command line as well as in a batch file.

When used in a batch file the syntax is as follows

FOR %%variable IN (set) DO command parameters

When used on the DOS command line the syntax is as follows

FOR %variable IN (set) DO command paramaters

Excerpt from Special Edition Using MS-DOS 6.22 3rd edition -- Jim Cooper.
  • monte
  • Born
  • Born
  • monte
  • Posts: 1

Post 3+ Months Ago

@REM initialize test value to be "true"
@SET intCounter=1


@REM test condition
@IF %intCounter% GTR 10 (GOTO wend)

@REM procedure where condition is "true"
@echo %intCounter%

@REM set new test value
@SET /a intCounter=intCounter+1

@REM loop
@GOTO while



Post Information

  • Total Posts in this topic: 3 posts
  • Users browsing this forum: No registered users and 82 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.