FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for CA-Clipper progress bar
Posts: 43
Joined: Wed Jun 20, 2012 04:07 AM
progress bar
Posted: Fri Jan 25, 2013 02:02 PM

Hi,
Currently I am building a .dbf of filenames from a Windows folder and its subfolders.

I wish to have a progress bar to display "while" the .dbf is being populated.

I have inserted a progress bar from the testmex.prg sample into my code.

Problem is the progress bar dialog is only displayed upon completion, not while the .dbf is building.

I am unsure how to accomplish the task.

At the risk of leaving something out , I include the entire function.

Any help appreciated,
Bruce S.

FWH 12.06 June 2012
Harbour 3.1.0 Rev.17222
bcc582
Clipper - 5.3b

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Func heat_update() // Date : 10/11/12
// Use : Assemble Q:\data folder and file information
// for millcerts

local aFolders
local nFol_len

local nOffset := 3 // set at 3 to bypass . & .. parent <dir>
local nIndex := 1

local cFol_nam
local nFol_max

local aSub_Fldr
local nSub_max := 0
local nSub_index := 3 // set at 3 to bypass . & .. parent <dir>

local nRec_ctr := 0
local cSto

local cStart := time()
local cStop
local cElapsed

local oPrg
local oProg1

local oDlg
local nActual := 0
local oMeter
local nTotal
local nTimes := 0

// stats dialog
local oStat
local fntArial
local oSay
local cStat_msg

Local hFile
Local aInfo

local cCert_seg := "q:\data\millcert\"
local cFile := "m_cert.dbf"

local times
local nActual3 := 10 //6000
local ometer3

USE ( cCert_seg + cFile)  alias MC
DELE ALL
PACK


 //msginfo( cCert_seg,&quot;Cert&quot; )


 // build array of millcert folder names
 aFolders := directory( cCert_seg, &quot;D&quot; )

 nFol_len := len(aFolders)     // count all folders

 nFol_len ++   // add one to cover the one we are starting on


If lIsDir( cCert_seg )     // does folder exist

//MTR

  DEFINE FONT fntArial NAME &quot;Arial&quot; SIZE 0, -12  //BOLD


  DEFINE DIALOG oDlg  FROM 14,65 TO 21, 93 ;
      TITLE &quot;  Record  total &quot;      //+  trans(lastrec(),'999,999')



 // meter 3 from testmex.prg           w   h
 @ 5, 5 METEREX oMeter3 VAR nActual3 SIZE 100, 10 TOTAL 100 PIXEL;
     GRADIENT CHUNK { { 1/2, nRGB( 255, 251, 229 ), nRGB( 250, 223, 143 ) } ,;
              { 1/2, nRGB( 244, 194,  51 ), nRGB( 252, 235, 173 ) } };
     GRADIENT TRACK { { 1/2, nRGB( 198, 203, 213 ), nRGB( 219, 224, 233 ) } ,;
              { 1/2, nRGB( 224, 238, 237 ), nRGB( 224, 238, 237 ) } };
     ROUND LINECOLORS CLR_BLACK, CLR_WHITE



 Do while nOffset &lt;  nFol_len

   cFol_nam := aFolders[nOffset][1]   // current folder name

   // Sub folder info

   // directory of sub folder
   aSub_Fldr := directory( cCert_seg + cFol_nam + &quot;\*.*&quot;,&quot;D&quot;)

   nSub_max := len(aSub_Fldr)     // # of files
   // ?minus . &amp; ..
   // will I need when sub folders are involved


   Do while nSub_index &lt;= nSub_max    // store sub folder contents

 APPEND BLANK

 cSto := iif(upper(right(aSub_Fldr[nSub_index][1],3)) = &quot;PDF&quot; ,&quot;FL&quot;,&quot;FD&quot;)


 Repl;
      MC-&gt;heat      with  aSub_Fldr[nSub_index][1],;
      MC-&gt;sto       with  cSto            ,;
      MC-&gt;pri_supl with  left(cFol_nam,8)


     Automatic( oMeter3, @nActual3 )


 nRec_ctr++  // may be out by . &amp; .. ??
 nSub_index++



   Enddo  //sub_max


   nSub_index := 3        // set to 3 to bypass . &amp; ..
   nOffset++

 Enddo    //nFol_len

 dbcommit()


else

// notify if no folder available
msginfo( &quot;Q:\data\millcert does not exist&quot;,&quot;Info&quot; )
return nil


endif

////////////////////////////////////////////
// display processing stats

cStop := time()
cElapsed := cStop - cStart

@  1.00 , 1.0 say trans(lastrec(),'999,999') + &quot;   records &quot; ;
              FONT fntArial SIZE 180,80

@  1.75 , 1.0 say trans(nRec_ctr ,'999,999') + &quot;   processed &quot; ;
              FONT fntArial SIZE 180,80

@  2.50 , 1.5 say substr(cElapsed,1,5) + &quot;   seconds  &quot; ;
              FONT fntArial SIZE 180,80

ACTIVATE DIALOG oDlg

fntArial:End()

DBCLOSEALL()

return nil // heat_update
//----------------------------------------------------------------------------//

FUNC Automatic( oMeter, nActual )

LOCAL n
LOCAL nFrom := nActual

FOR n = nFrom TO oMeter:nTotal step 0.001
nActual = n
oMeter:Set( nActual )
NEXT
nActual = oMeter:nTotal
oMeter:Set( nActual )

RETURN NIL

//--------------------------------------------------------

<<<<<<<<<<<<<<<<

Posts: 159
Joined: Wed Mar 28, 2007 01:19 PM
Re: progress bar
Posted: Sat Jan 26, 2013 08:05 PM
Bruce, you can start with this example
Code (fw): Select all Collapse
/*  SAMPLES\PROGTIME.PRG modified  */
#include "FiveWin.ch"

function Main()
local oDlg, oProg, aFiles:=directory(".\"), oSy, cFile:=""
   DEFINE DIALOG oDlg TITLE HB_Curdrive()+":\"+Curdir()+" Directory Scan"
   @ 1, 1 PROGRESS oProg POSITION 0 SIZE 150, 10
   @ 2, 10 say oSy VAR cFile size 100, 12 
   @ 2.5,  6 BUTTON "Scan" ACTION DoScan(aFiles, oProg, oSy, @cFile)
   @ 2.5, 14 BUTTON "End" ACTION oDlg:End()
   ACTIVATE DIALOG oDlg CENTER
return nil   
*
Function DoScan(aFiles, oProg, oSy, cFile)
local nI
   oProg:nPosition=0
   oProg:SetRange( 0, len(aFiles))
for nI=1 to len(aFiles)
    oProg:nPosition += 1
    cFile=upper(aFiles[nI, 1])
    oSy:refresh() 
    syswait()
next
return nil

the "syswait()" is only there to slower the operation.
Regards, Euclides
Posts: 43
Joined: Wed Jun 20, 2012 04:07 AM
Re: progress bar
Posted: Sun Jan 27, 2013 05:50 PM

Euclides,

       Thank you, I will pursue

Bruce

Continue the discussion