Processa + ProcRegua + IncProcCreates the progress window, defines the meter total and increments progress during processing.
AdvPL GuideProcessa · ProcRegua · IncProc · RptStatus · SetRegua · IncReguaOrganize long-running processes with progress windows and progress bars.
Progress meters help users understand that a long routine is still running. In AdvPL, the common Processa flow uses an action block, ProcRegua to set the total and IncProc to advance the meter. In another visual model, RptStatus works with SetRegua and IncRegua. Although the names are similar, the pairs belong to different flows; mixing them without validating the context may produce unexpected behavior.
Processa · ProcRegua · IncProc · RptStatus · SetRegua · IncReguaProcessa + ProcRegua + IncProcCreates the progress window, defines the meter total and increments progress during processing.
RptStatus + SetRegua + IncReguaDisplays a status window and controls the progress bar with functions for that context.
Conceptual content. Open each function page for syntax and examples.
#Include "TOTVS.ch"
User Function RunProcess()
Local bAction := {|lEnd| U_ProcessItems(@lEnd)}
Local cTitle := "Processing"
Local cMsg := "Processing items..."
Local lAbort := .T.
Processa(bAction, cTitle, cMsg, lAbort)
Return
User Function ProcessItems(lEnd)
Local nItem
Local nTotal := 100
ProcRegua(nTotal)
For nItem := 1 To nTotal
If lEnd
Exit
EndIf
// Process the item here.
IncProc()
Next nItem
ReturnThe window created by Processa follows the loop. ProcRegua defines the total and IncProc advances the meter for each processed item.
#Include "TOTVS.ch"
#Include "TopConn.ch"
User Function RunRptStatus()
Local aArea := GetArea()
RptStatus({|| U_QueryMeter()}, "Please wait...", "Running query...")
RestArea(aArea)
Return
User Function QueryMeter()
Local aArea := GetArea()
Local nTotal := 0
TCQuery "SELECT BM_GRUPO, BM_DESC FROM %table:SBM% SBM WHERE SBM.D_E_L_E_T_ = ' '" New Alias "QRY_AUX"
Count To nTotal
SetRegua(nTotal)
QRY_AUX->(DbGoTop())
While ! QRY_AUX->(Eof())
// Process current row.
IncRegua()
QRY_AUX->(DbSkip())
EndDo
QRY_AUX->(DbCloseArea())
RestArea(aArea)
ReturnRptStatus opens a status window. SetRegua defines the total and IncRegua increments the bar as records are processed.
© 2026 Usina.BR. All rights reserved. TOTVS, Protheus, Microsiga and their respective logos are trademarks of their owners. AdvPL Guide is independent and uses limited, attributed excerpts justified by educational purposes. See the Terms of Use. Terms of Use
Comments
There are no approved comments yet.
Sign in with Google or Microsoft to comment.