Page 1 of 1
Countdown script
Posted: 19 Oct 2008 08:24
by thepierre
Hello all. I am new to DOS scripting, and we have an assignment at school. We were told:
"Write a script that displays odd numbers beginning with 49 and descending until ending with 1."
That was all we were given, I have no idea where to even start. Can someone please lead me in the correct direction!
Thank you so much!!
Posted: 19 Oct 2008 12:22
by DosItHelp
thepierre,
Here is a hint:
Callup the help for the FOR command and read.
From command line run: FOR /?
or click here
http://www.dostips.com/DosCommandIndex.htm#FOR
DosItHelp?
Posted: 21 Oct 2008 09:32
by thepierre
I see what it is talking about, I am just not getting the variable part... and how do I know what command to run. That did help though!
I just don't understand how to form it so that it will display the numbers to the screen, here is what I have:
FOR /L %variable IN (49,-2,1) DO command
I start at 49, it is counting down by 2, so I get my odd numbers, and it ends at 1.
I just don't get what the variable is, or what the command is.
Posted: 22 Oct 2008 18:50
by DosItHelp
More hints for you:
FOR loop variables can only be one letter long
ECHO outputs a message on the screen, message can have variables in it.
http://www.dostips.com/DosCommandIndex.htm#ECHO
Make sure you post your solution here