Processbar won't work

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Adrianvdh
Posts: 177
Joined: 16 May 2013 13:00

Processbar won't work

#1 Post by Adrianvdh » 09 Aug 2013 04:02

Hello everyone, this is probably also just another simple error, but I can't figure it out. A few years ago and remember about it. So I implemented it into my code and it does not work, but on a normal batch file it does.

[code]
echo off
cls
echo [Connecting]
echo.
echo ±±±±±±±±±±±±±±±±±±±±±±±±±±±
ping localhost -n 2.5 >nul
cls
echo [Connecting]
echo.
echo ÛÛ±±±±±±±±±±±±±±±±±±±±±±±±±
ping localhost -n 2.5 >nul
cls
echo [Connecting]
echo.
echo ÛÛÛÛ±±±±±±±±±±±±±±±±±±±±±±±
ping localhost -n 2.5 >nul
cls
echo [Connecting]
echo.
echo ÛÛÛÛÛÛÛ±±±±±±±±±±±±±±±±±±±±
ping localhost -n 2.5 >nul
cls
echo [Connecting]
echo.
echo ÛÛÛÛÛÛÛÛÛÛÛÛ±±±±±±±±±±±±±±±
ping localhost -n 2.5 >nul
cls
echo [Connecting]
echo.
echo ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ±±±±±±±
ping localhost -n 2.5 >nul
cls
echo [Connected!]
echo.
echo ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ
ping localhost -n 2.5 >nul
[/code[

Any help would be great.

Thanks for your time ;)

Magialisk
Posts: 104
Joined: 25 Jul 2013 19:00

Re: Processbar won't work

#2 Post by Magialisk » 09 Aug 2013 04:32

I'm not sure what you mean by saying it doesn't work in your code but it works in a normal batch file?

A few things I would recommend instead of what you're doing:
1.) DosTips has two functions called "InitProgress" and "DoProgress" that use the title bar of the window to hold a progress meter. I think it looks nice. You can grab those here: http://www.dostips.com/DtCodeCmdLib.php
2.) In your ping command you have -n 2.5, which tells ping to send 2.5 echo requests, which is impossible. This won't cause it to stop running, it will just ignore the '.5' and send 2 requests, but I can't help but wonder if instead you wanted to wait 2.5 seconds, in which case I think you're looking for the '-w' option
3.) Finally, instead of using echo and cls I'd recommend set /p. I whipped up some code that seems to work, but I lowered the ping count to 1, you can adjust the ping command to get your timing right.

Code: Select all

@echo off

::define a Carriage Return string, only useable as !CR!
for /f %%a in ('copy /Z "%~dpf0" nul') do set "CR=%%a"

SETLOCAL ENABLEDELAYEDEXPANSION
cls
echo [Connecting]
set /p ans="±±±±±±±±±±±±±±±±±±±±±±±±!CR!" <nul
FOR /L %%a IN (1,1,6) DO (
   ping localhost -n 1 >nul
   set /p ans="ÛÛÛÛ" <nul
)
cls
echo [Connected!]
set /p ans="ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ" <nul
echo.
echo.
echo now you can do whatever else
pause

Adrianvdh
Posts: 177
Joined: 16 May 2013 13:00

Re: Processbar won't work

#3 Post by Adrianvdh » 09 Aug 2013 05:49

Hey, to show you what I meant by not working in my bat file, I will post a snapshot. Both and your and my code does not work in my own bat file, but I create new one and post all the code I posted in post 1 or your code it works, but not in mine...

P.S 1. I don't know if you can upload an images to with this forum software, so I will just host in myself...

http://www.mediafire.com/view/a4xxox4ix ... s_.bat.jpg

Any help?

P.S 2: I have know idea how to use the 2 functions you gave me?

Post Reply