Solving development problems  |  About this blog

Archive for the ‘listing’ tag

Number list generator

For example you want to produce a text file with all the integers in order from 1 to 2000, and have the file named “List2000.txt” your command line would look like this:

  • Start DOS prompt.
  • Type:
    C:\>for /L %i in (1,1,2000) do @echo %i >>List2000.txt
  • The three integers (no fractions!) within the parentheses are start, step, and end numbers. Here we start with 1, go by steps of 1, till we hit 2000, and write the file.
  • Hit <ENTER>. The computer chugs for a few seconds, and generates the file.
  • To go backwards from 100 to 0 by step 2, the command line would read:
    C:\>for /L %i in (100,-2,0) do @echo %i >>List-100a.txt

Written by Avivo

April 6th, 2009 at 9:53 am