udfProgressbar
udfProgressbarV
void udfProgressbar (str, int, int)
void udfProgressbarV (str, int, int)
;------------------------------------------------------------------------------------------------------------------------------------------
#DefineFunction udfProgressbar (strCaption, intScale, intCurrent)
If intCurrent > intScale Then Return
If intCurrent < 0 Then Return
ptrP = PtrPersistent (intV, 0)
If !*ptrP
   *ptrP = 1
   BoxesUp ("250,150,664,230", @NORMAL) ; Adjust screen position of the box.
   BoxColor (1, "255,255,0", "0")
   BoxTextColor (1, "0,0,0")
   BoxCaption (1, strCaption)
   BoxTextFont (1, "System", 40, 0, 1)
   BoxDataTag (1, 1)
   If !IsDefined (intCurrent) Then intCurrent = 0
   If !IsDefined (intScale) Then intScale = 100
EndIf
intLength = 50 ; User configurable length (width of the bar) ; Adjust width of the box too, see BoxesUp statement above.
intPercent = 100 * intCurrent / intScale
intDone = intLength * intCurrent / intScale
strPbar = "[" : StrFix (StrFixLeft (" " : intCurrent : "/" : intScale, "-", (intLength / 2)) : " = " : intPercent : "%%" : " ", "-", intLength) : "]"
strPbar = strPbar : @CRLF : "[" : StrFill ("*", intDone) : StrFill ("-", intLength - intDone) : "]"
BoxDataClear (1, 1)
BoxText (strPbar)
If intCurrent >= intScale
   BoxDestroy (1)
   *ptrP = 0
EndIf
Return
;..........................................................................................................................................
; Detlev Dalitz.20010727.20100201.
;..........................................................................................................................................
#EndFunction
;------------------------------------------------------------------------------------------------------------------------------------------


;------------------------------------------------------------------------------------------------------------------------------------------
#DefineFunction udfProgressbarV (strCaption, intScale, intCurrent)
If intCurrent > intScale Then Return
If intCurrent < 0 Then Return
ptrP = PtrPersistent (intV, 0)
If !*ptrP
   *ptrP = 1
   BoxesUp ("800,200,840,690", @NORMAL) ; Adjust screen position of the box.
   BoxColor (1, "255,255,0", "0")
   BoxTextColor (1, "0,0,0")
   BoxCaption (1, strCaption)
   BoxTextFont (1, "System", 40, 0, 1)
   BoxDataTag (1, 1)
   If !IsDefined (intCurrent) Then intCurrent = 0
   If !IsDefined (intScale) Then intScale = 100
EndIf
intLength = 20 ; User configurable length (height of the bar) ; Adjust height of the box too, see BoxesUp statement above.
intPercent = 100 * intCurrent / intScale
intDone = intLength * intCurrent / intScale
intScaleLength = StrLen (intScale)
strPbar = StrFixLeft (intPercent, " ", Max (3, intScaleLength)) : "%%" : @CR
strPbar = strPbar : StrFill (@CR, intLength - intDone) : StrFill ("***" : @CR, intDone * 4)
strPbar = strPbar : StrFixLeft (intCurrent, " ", Max (4, intScaleLength)) : @CR : StrFixLeft (intScale, " ", Max (4, intScaleLength))
BoxDataClear (1, 1)
BoxText (strPbar)
If intCurrent >= intScale
   BoxDestroy (1)
   *ptrP = 0
EndIf
Return
;..........................................................................................................................................
; Detlev Dalitz.20010727.20100201.
;..........................................................................................................................................
#EndFunction
;------------------------------------------------------------------------------------------------------------------------------------------


; Test.
; Simple Progressbar.

intScale = 100
For intCurrent = 0 To intScale
   udfProgressbar ("Fortschritt", intScale, intCurrent)
   TimeDelay (.1)
   ; Do your work here.
Next


intScale = 100
For intCurrent = intScale To 0 By -1
   udfProgressbar ("Fortschritt", intScale, intCurrent)
   TimeDelay (.1)
   ; Do your work here.
Next


intScale = 1000
For intCurrent = 400 To 1100
   udfProgressbar ("Fortschritt", intScale, intCurrent)
   Yield
   Yield
   ; Do your work here.
Next


intScale = 1000
For intCurrent = 0 To intScale
   udfProgressbarV ("Fortschritt", intScale, intCurrent)
   Yield
   Yield
   ; Do your work here.
Next


intScale = 100
For intRandom = 0 To 200
   intCurrent = Random (intScale)
   udfProgressbarV ("Fortschritt", intScale, intCurrent)
   TimeDelay (.1)
   ; Do your work here.
Next

Exit