0

I have tried to make Windows batch file that blinking the word "Wait" & "Wait..". I tried the following code:

@Echo OFF
setlocal EnableDelayedExpansion
for /f %%a in ('copy /Z "%~f0" nul') do set "CR=%%a"
SET p=-1
set num=2
set st[1]=Wait
set st[2]=Wait..
set st[3]=eer

:LOOP

if /i %num% equ 1 (
set num=2
) else (
set num=1
)
<nul set /P "=!st[%num%]!!CR!"

TIMEOUT /T 1 >NUL






GOTO :LOOP

The problem here, the IF seems to be worked only one time. i.e running the batch makes it prompt "Wait" only one time, then "Wait.." forever. What is the mistake here?

1 Answer 1

1

You problem is not the if (that works as intended), your problem are the spaces that should delete/overwrite the dots.

set "st[1]=Wait  "
set "st[2]=Wait.."
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.