Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to update progressbar value during tableupdate?
Message
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Miscellaneous
Thread ID:
00050346
Message ID:
00052593
Views:
33
>Hi,
>
>I have sometimes the need to do a batch update on a table buffered table: something in the range of 8.000 records and the underlying table has about 300.000 records. This may take several minutes and I'd like to show some sort of thermometer to the user. But I find no way to do it since I have no clue on how the update process is going. I am using a transaction like this:
>
> BEGIN TRANSACTION
> IF TABLEUPDATE(.T.)
> END TRANSACTION
> ELSE
> ROLLBACK
> TABLEREVERT(.T.)
> ErrorMsg(this.cMsgUpdateFailed + " Table: WageHead")
> SELECT (lnCurSel)
> RETURN .F.
> ENDIF
>
>Any idea how to update the progressbar while I am in the transaction?
>
>José
------------------------------------
Here is the final answer to this question, as suggested by Ed Leafe:

The scheme based on GETNEXMODIFIED() works perfectly and the performance hit seems minimum. I've also added some code to refresh the thermometer only once for every percent increase. Here is the code for the benefit of all.

José


LOCAL i, ;
lnMax, ;
lnStep, ;
llToast, ;
lnNext

i = 0
lnMax = 0
lnStep = 0
llToast = .F.

*-- Count the total number of items that were modified
lnNext = GETNEXTMODIFIED(0)

DO WHILE lnNext # 0
GO (lnNext)
lnNext = GETNEXTMODIFIED(lnNext)
i = i + 1
ENDDO
lnMax = i


lnNext = GETNEXTMODIFIED(0)
i = 0
lnStep = INT( lnMax / 100)

BEGIN TRANSACTION
DO WHILE lnNext # 0
GO (lnNext)
IF ! TABLEUPDATE()
llToast = .T.
EXIT
ENDIF
IF MOD ( i , lnStep) = 0
this.cProgressMeter1.RefreshDisplay(i, lnMax)
ENDIF
lnNext = GETNEXTMODIFIED(lnNext)
i = i + 1
ENDDO

this.cProgressMeter1.Reset()

IF llToast
ROLLBACK
TABLEREVERT(.T.)
ErrorMsg(this.cMsgUpdateFailed + " Table: Présence")
RETURN .F.
ELSE
END TRANSACTION
ENDIF
Previous
Reply
Map
View

Click here to load this message in the networking platform