Page 1 of 1

Progress bar

Posted: 13 Jun 2014 13:52
by Rafhack
Any suggestions or improvements?


Code: Select all

@echo off
::PROGRESS BAR
setlocal enabledelayedexpansion
set /a full = 23
for /l %%a in (1,1,%full%) do (
 CALL:ADDSPACE)
for /l %%b in (1,1,%full%) do (
 set /a actu=%%b
 set /a org=!actu! * 100
 set /a org= org / full
 CALL:PROGRESS %%b
)
del _temp.bat
exit/b
:ADDSPACE
 set "fullBar=%fullBar%_"
 set "tags=%tags%#"
 exit/b
:PROGRESS
set number=%~1
set /a pct=full-number
 (
  echo/echo/[%%tags:~0,%~1%%%%fullBar:~0,%pct%%%] %org%%%%%
 )>_temp.bat
 call _temp.bat
 timeout 1 1>nul&cls

Re: Progress bar

Posted: 13 Jun 2014 16:18
by einstein1969
Hi rafhack!

nice small progress.

Why use a file? I think that you can do without using a file.

general piece of code that is in progress bars:

Code: Select all

@echo off
::PROGRESS BAR
setlocal enabledelayedexpansion
for /f %%a in ('copy /Z "%~f0" nul') do set "CR=%%a"
set /a full = 23
for /l %%a in (1,1,%full%) do (
 CALL:ADDSPACE)
for /l %%b in (1,1,%full%) do (
 set /a actu=%%b
 set /a org=!actu! * 100
 set /a org= org / full
 CALL:PROGRESS %%b
)
del _temp.bat
exit/b
:ADDSPACE
 set "fullBar=%fullBar%_"
 set "tags=%tags%#"
 exit/b
:PROGRESS
set number=%~1
set /a pct=full-number
 (
  echo/set/p".=[%%tags:~0,%~1%%%%fullBar:~0,%pct%%%] %org%%%%% ^!CR^!"^<nul
 )>_temp.bat
 call _temp.bat
 timeout 1 1>nul
exit/b


einstein1969

Re: Progress bar

Posted: 13 Jun 2014 16:21
by einstein1969
my recent study on progress bar:

Code: Select all

@echo off & setlocal  EnableDelayedExpansion

for /f %%a in ('copy /Z "%~f0" nul') do set "CR=%%a"

rem    12345678901234567890123456789012345678901234567890
set L0=__________________________________________________
set L1=°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°
set L2=±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±
set L3=²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²
set L4=ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ

echo(

set /a max=1000+!random!

set /a parz=!max!/4, Max=parz*4

for /L %%k in (0,1,3) do (

set /a n=%%k+1
set LL0=!L%%k!

for %%n in (!n!) do set LL1=!L%%n!

For /L %%i in (1,1,!Parz!) do (


set /a rapp=%%i*50/!parz!

set /a d=50-rapp

for %%r in (!rapp!) do for %%d in (!d!) do <nul set /p "=^<!LL1:~0,%%r!!LL0:~0,%%d!^> %%i/!Max! - !Time! !CR!"
rem >nul ping -w 500 -n 1 192.0.2.0

)


einstein1969

Re: Progress bar

Posted: 13 Jun 2014 16:44
by Rafhack
Nice examples! Thank you!