Countdown script

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
thepierre
Posts: 2
Joined: 19 Oct 2008 08:19

Countdown script

#1 Post by thepierre » 19 Oct 2008 08:24

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!!

DosItHelp
Expert
Posts: 239
Joined: 18 Feb 2006 19:54

#2 Post by DosItHelp » 19 Oct 2008 12:22

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? :wink:

thepierre
Posts: 2
Joined: 19 Oct 2008 08:19

#3 Post by thepierre » 21 Oct 2008 09:32

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.

DosItHelp
Expert
Posts: 239
Joined: 18 Feb 2006 19:54

#4 Post by DosItHelp » 22 Oct 2008 18:50

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 :wink:

Post Reply