code help!

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
xhai
Posts: 39
Joined: 13 Jun 2013 09:33

code help!

#1 Post by xhai » 03 Sep 2014 00:30

Code: Select all

@ECHO OFF
:start
echo "Please do not touch anything during patching process!"
echo "Stage 1 of 5 (will take about 15 minutes depending on CPU speed)"
echo checking
goto :a

:a
cls
echo "Stage 2 of 5 (will take about 5 minutes depending on CPU speed)"
rem commands
goto :b

:b
cls
echo "Stage 3 of 5 (will take about 10 minutes depending on CPU speed)"
echo verifing
goto :c

:c
cls
echo "Stage 4 of 5 (will take about 10 minutes depending on CPU speed)"
rem commands
goto: d

:d
cls
echo "Stage 5 of 5 (will take about 10 minutes depending on CPU speed)"
pause
exit /b


I'm want the no. display in the box

Ex. Stage [1] of [5] (will take about 15 minutes depending on CPU speed)

the next output should be like this..

Ex. Stage [2] of [5] (will take about 10 minutes depending on CPU speed)

not this

Stage [1] of [5] (will take about 15 minutes depending on CPU speed)
Stage [2] of [5] (will take about 10 minutes depending on CPU speed)

thank you,

ShadowThief
Expert
Posts: 1160
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: code help!

#2 Post by ShadowThief » 03 Sep 2014 01:12

I'm confused. The code you posted already displays the status on one line.
Image

ShadowThief
Expert
Posts: 1160
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: code help!

#3 Post by ShadowThief » 03 Sep 2014 01:13

Although I should also point out that goto: d should actually be goto :d

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: code help!

#4 Post by foxidrive » 03 Sep 2014 01:32

Xhai, is the patching done in 5 separate commands, so that you can display your messages before each one?

xhai
Posts: 39
Joined: 13 Jun 2013 09:33

Re: code help!

#5 Post by xhai » 03 Sep 2014 05:38

foxidrive wrote:Xhai, is the patching done in 5 separate commands, so that you can display your messages before each one?


before patching i need to check this following..
1. detect if file already exist
2. verify the size
3. check crc
4. if all are correct then it will go to patching


if you remember my previous post this codes are related, if %skip%==disable it will not go to step 1-3 instead directly to step 4..
on step 5 I'm still thingking what to do..

I already have codes from 1-3 I want those steps have a little bit animated, displaying the no. in the a box

@ShadowThief
yap it display on one line but it doesn't display the rest it skip step 1-4...

Maybe I'm wrong displaying it on one line... or should I display them all


thank you,

ShadowThief
Expert
Posts: 1160
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: code help!

#6 Post by ShadowThief » 03 Sep 2014 05:41

It doesn't skip anything. You don't pause between steps to see the output displayed so the screen gets cleared before you can see anything. Put a pause before each goto and you'll see it work.

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: code help!

#7 Post by foxidrive » 03 Sep 2014 07:39

xhai wrote:
foxidrive wrote:Xhai, is the patching done in 5 separate commands, so that you can display your messages before each one?


before patching i need to check this following..
1. detect if file already exist
2. verify the size
3. check crc
4. if all are correct then it will go to patching

I already have codes from 1-3 I want those steps have a little bit animated, displaying the no. in the a box


Steps 1 and 2 are pretty much instant aren't they?

There are clever codes to give you animated sequences but they mostly only operate when the batch file is not doing anything else.
When the patching is happening then the animated sequences cannot be displayed, in the same window.

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: code help!

#8 Post by foxidrive » 03 Sep 2014 07:41

I have a few animated batches - here's one:

Code: Select all

::Demo-WaitMsg.cmd:::::::::::::::::::::::::::::::::::::::::::::::::::
@echo off
Call :WaitMsg ....Whatever you want to display....
pause
goto :EOF
::Sub WaitMsg::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:WaitMsg messages containing no qoutes
setlocal&set "LoopCnt=3000"&set "cnt=0"&set "step=1"&set text=%*
:WaitMLoop
cls&echo.&set /A cnt+=step
call set txt=%%text:~-%cnt%%%
for %%a in (/ - \ ^| / - \ ^|) do (echo ^%%a%txt%
for /L %%b in (1,1,%LoopCnt%) do set dummy=%%b
cls & echo.)
if %cnt%. EQU 0. goto :eof
if "%txt%" NEQ "%text%" goto :WaitMLoop
echo %text%
ping -n 3 127.0.0.1 >nul
cls&echo.&set step=-1
goto :WaitMLoop
::Demo-WaitMsg.cmd:::::::::::::::::::::::::::::::::::::::::::::::::::
:: Matthias Tacke



And another:

Code: Select all


@echo off
cls & echo.
set "text=....Waiting for the network to startup...."

:: calculate the length of the text string
for /f "tokens=1* delims=:" %%a in (
'^(for %%i in ^("%text%" .^) do @echo %%i^) ^| findstr /o .^| ^
findstr /v /b 0') do set /a v=%%~a-5

for /L %%a in (1,1,%v%) do call set "txt=%%text:~0,%%a%%"&call :show out
echo %text%
ping -n 3 127.0.0.1 >nul
cls & echo(
for /L %%a in (2,1,%v%) do call set "txt=%%text:~%%a%%"&call :show in

echo Please wait...
Rem Startup routine goes here
pause
goto :EOF

:show
for %%a in (/ - \ ^| / - \ ^|) do (
if %1==out echo %txt%^%%a
if %1==in  echo ^%%a%txt%
for /L %%b in (1,1,1000) do set dummy=%%b
cls & echo(
)

xhai
Posts: 39
Joined: 13 Jun 2013 09:33

Re: code help!

#9 Post by xhai » 03 Sep 2014 13:50

Thanks foxi I love those codes..

Post Reply