I am using PROGRESS object while Re-indexing my DBF files. Unfortunately The progress Bar display reaches the extreme right end, even when the percentage have reached only 33%.
The percentage is calculated as
(nCurrentNtxCount/TotalNoOf Indexes) * 100
I don't know where I have went wrong
Screen Snapshot
My Code
- Code: Select all Expand view
*------------------------------------------------------------------*
Function ReIndex()
*------------------------------------------------------------------*
Local oDlg,nStyle,oProg
nStyle :=nOR( DS_MODALFRAME, WS_POPUP, WS_CAPTION ) // Removes the ? and x on the dialogue title
DEFINE DIALOG oDlg TITLE "Reindex Data Files" STYLE nStyle SIZE 600,300 PIXEL ;
@01,01 PROGRESS oProg POSITION 0 SIZE 250, 8
@03,01 BUTTON oBtn PROMPT "Reindex" SIZE 40,12 ACTION {oProg:SetStep( 1 ) , oProg:SetRange( 1, 100 ), DoIndexing(oDlg,oProg) }
@03,10 BUTTON oBtn2 PROMPT "Close" SIZE 40,12 ACTION { CloseDbf("All"), oDlg:End() }
ACTIVATE DIALOG oDlg CENTERED
Close Data
Return .T.
*------------------------------------------------------------------*
Function DoIndexing(oDlg,oProg) // called Sam.prg
*------------------------------------------------------------------*
Local nNtxNo,n
Use DBFS
count to nNtxNo for !empty(NTXNAME)
n:=0
Sele DBFS
Go top
Do while !eof()
if !empty(ntxkey)
sele c
use
if ! Netuse((MastPath+alltrim(dbfs->DBFNAME)),EXCLUS_OPEN,USR_WRK_AREA,5)
*loop
endi
@04,01 say "DBF "+dbfs->DBFNAME+" Records : "+str(reccount(),6)
@05,01 say padc("Indexing on "+alltrim(dbfs->NTXKEY)+' to '+alltrim(dbfs->NTXNAME)+'.NTX',78)
inde on &(alltrim(dbfs->NTXKEY)) to &(Mastpath+alltrim(dbfs->NTXNAME))
n++
nPercent := VAL( STR(( n / nNtxNo ) * 100, 3, 0 ))
* nPercent := ( n / nNtxNo ) * 100
MsgInfo(str(nPercent)+"%")
oProg:StepIt()
oProg:nPosition += nPercent
Endif
Sele dbfs
skip
Enddo
Close Data
oDlg:End()
Return .T.
Regards
Anser