Click to See Complete Forum and Search --> : DOS Batch File Woes


bpat1434
03-23-2006, 01:58 AM
I'm just tryin to test something out, and for some odd reason I can't get it to work.
::::::::::::::::::::::::::::::::::::::::::
:: Test of Loop ::
::::::::::::::::::::::::::::::::::::::::::

@ECHO OFF
TITLE Starting the Loop!!!!!

set k=0
set i=0
set max=80
GOTO Switch

:Loop
SET L=%k%+1
SET k=%L%
IF %k%==%max% GOTO Finished
ELSE GOTO Switch

:Switch
IF %i%==0 GOTO part1
IF %i%==1 GOTO part2
IF %i%==2 GOTO part3
IF %i%==3 GOTO part4

:part1
CLS
ECHO Please Wait . . . |
set i=1
GOTO Loop

:part2
CLS
ECHO Please Wait . . . /
set i=2
GOTO Loop

:part3
CLS
ECHO Please Wait . . . -
set i=3
GOTO Loop

:part4
CLS
ECHO Please Wait . . . \
set i=0
GOTO Loop

:Finished
CLS
ECHO Finished The Loop!
PAUSE
EXIT
Basically, it's supposed to give me something like:
Please Wait... with a little spinning icon at the end...

Unfortunately, the output I get is:
The syntax of the command is incorrect

WTH? I don't see anything wrong!! Do you?

The ultimate goal is to incorporate this in aother batch file I have for my job, so it gives some feedback as to what's going on (so the dumbasses know what's going on). So... any idea what's wrong? I know it's Windows DOS scripting.... but it's what we use!!

Weedpacket
03-23-2006, 04:53 AM
Try quoting the echo strings; you'll also need to writeSET /a L=%k%+1otherwise the expression won't be evaluated. Oh, and the ELSE needs to be on the same line as the IF (newline-delimited commands, blah...)

bpat1434
03-24-2006, 01:04 AM
1.) Quotes around the echoed stuff puts quotes around the printed text in the command box. So that's not it (I tried previously)

2.) What in the world... /a? What does that do I never saw that.... is it for each set, or just the updates that need math?

Updated Code
::::::::::::::::::::::::::::::::::::::::::
:: Test of Loop ::
::::::::::::::::::::::::::::::::::::::::::

@ECHO OFF
TITLE Starting the Loop!!!!!

set k=0
set i=0
set max=80
GOTO Switch

:Loop
SET /a k=%k%+1
IF %k%==%max% GOTO Finished ELSE GOTO Switch

:Switch
IF %i%==0 GOTO part1
IF %i%==1 GOTO part2
IF %i%==2 GOTO part3
IF %i%==3 GOTO part4

:part1
CLS
ECHO Please Wait . . . |
set i=1
GOTO Loop

:part2
CLS
ECHO Please Wait . . . /
set i=2
GOTO Loop

:part3
CLS
ECHO Please Wait . . . -
set i=3
GOTO Loop

:part4
CLS
ECHO Please Wait . . . \
set i=0
GOTO Loop

:Finished
CLS
ECHO Finished The Loop!
PAUSE
EXIT
Still the same result..... syntax of the command is incorrect....
Thank you MS for being so friggin vague....

Weedpacket
03-24-2006, 04:25 AM
just the updates that need mathYup, otherwise k becomes "0+1 ", "0+1+1", "0+1+1+1", ... and never manages to equal "80".

Quotes around the echoed stuff puts quotes around the printed text in the command box. So that's not it (I tried previously)Now I know there's a conspiracy, 'cos that's what did it for me. A difference in winderz versions? Would writing it in Javascript be easier?

Ah, hahahaaaaa.... me knows! me knows! Wawawawawa!
ECHO Please Wait . . . ^|etc.

What a stupid choice of escape character...

bpat1434
03-24-2006, 08:49 AM
lol... why can't it just be backslash.... stupid MS....

AND YES!!! IT WORKED!!!! THANK YOU SOOO MUCH!!!