WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Progress Bars

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Displaying a Progress Thermometer While Processing the Background

Keywords: thermometer boxes 

Question:

In the Box Drawing Demo.wbt, under the DOTHERM sub-procedure, there is a line "TimeDelay(Random(1.0)) ;Fake passage of time". Each time the program runs through this section, the completion bar is added to. I have a line that copies *.* files to another directory in my script. Is there a way I can use this thermometer to show how far along this copy is? Or, is BoxOpen, BoxShut my only choice for this?

Answer:

Option #1: See the function aStatusBar, in the ShellOp extender.

Option #2: I had the same question and the code below is a sample of how I handled this problem. In my example I just updated a Box with text to show percent complete, but I'm sure you can modify it to your graphic example.

;... misc code ... 
	BoxTitle("Updating Private Infobases") 
	dirchange("F:\rplbase") 
	files=fileitemize("*.nfo") 
	num_files=itemcount(files,@TAB) 
	for x = 1 to num_files 
		cur_file=itemextract(1,files,@TAB) 
		files=itemremove(1,files,@TAB) 
		line3="Copying:  %cur_file%" 
		line4= ((x*100)/num_files) 
		line4= strcat(line4," %% complete.") 
; The previous line makes line4 = "58% complete." or some other %age. 
		gosub update_display 
		if strindex(cur_file,"NA",0,@FWDSCAN) == 1 
			FileCopy(cur_file,"C:\Infobase\NA",@FALSE) 
		   else 
			FileCopy(cur_file,"C:\Infobase",@FALSE) 
		endif 
	next x 
	key=RegOpenKey(@REGCLASSES,"InfoUp") 
	RegSetValue(key,section2,"%yy%:%mm%:%dd%") 
	RegCloseKey(key) 
;... misc code ... 

Option #3: The copy *.* is a single operation. The thermometer bar cannot be updated there. The same problem exists with BoxOpen, etc in that it cannot be updated during the copy. However you may be able to change the *.* to a FOR loop where you copy each file individually and update the thermometer bar inbetween.

Something like:

;Do this code outside the FOR loop
DirChange("c:\Source\Directory")
thelist=FileItemize("*.*")
FILESTOCOPY=ItemCount(thelist,@tab)
FilesCopied=0
 
;then instead of the random fake passage of time...

thefile=ItemExtract(FilesCopied,thelist,@tab)
FileCopy(thefile,"C:\DestinationDir\*.*,0)

Article ID:   W12762
Filename:   Display a Progress Thermometer.txt
File Created: 2001:01:03:09:07:04
Last Updated: 2001:01:03:09:07:04