udfBoxProgressOpen
udfBoxProgressUpdate
bln udfBoxProgressOpen (str, str, str, str, flt)
bln udfBoxProgressUpdate (str, str, str, flt)
;=======================================================================================================================
; Simple Progress Bar
;
;    udfBoxProgressOpen
;    udfBoxProgressUpdate
;
;------------------------------------------------------------------------------------------------------------------------------------------
; Topic: Box-based progress bar
; Conf:  WinBatch Script Exchange
; From:  jmnelson john.w.nelson@mortenson.com
; Date:  Wednesday,  May 19,  2004 07:45 AM
;------------------------------------------------------------------------------------------------------------------------------------------
; (c)Detlev Dalitz.20090404.20110126.
;=======================================================================================================================


GoSub Define_Functions

; Test the progress bar.

udfBoxProgressOpen ("Sample progress bar", "", "", "", 0)  ; Initialize the progress bar.

intMin = 100
intMax = 200
For intItem = intMin To intMax
   fltPercentComplete = (((intItem - intMin) * 1.0 / (intMax - IntMin)) * 100)
   strCurrFile = FileCreateTemp ("TMP")
   udfBoxProgressUpdate ("Creating file " : intMax : "/" : intItem, strCurrFile, "Be patient ...", fltPercentComplete)
Next

udfBoxProgressUpdate ("Counting files:", "", "", 100)
TimeDelay (1)
udfBoxProgressUpdate ("Counting files:", "", "", 80)
TimeDelay (1)
udfBoxProgressUpdate ("Counting files:", "", "", 60)
TimeDelay (1)
udfBoxProgressUpdate ("Counting files:", "", "", 40)
TimeDelay (1)
udfBoxProgressUpdate ("Counting files:", "", "", 20)
TimeDelay (1)
udfBoxProgressUpdate ("Counting files:", "", "", 00)
TimeDelay (1)

DirChange (Environment ("TEMP"))
FileDelete ("TMP???.tmp")

BoxShut () ; Close box progress bar with BoxShut.

Exit


;=======================================================================================================================
:Define_Functions
;=======================================================================================================================

;-----------------------------------------------------------------------------------------------------------------------
#DefineFunction udfBoxProgressOpen (strMsgTitle, strMsgText1, strMsgText2, strMsgText3, fltPercentComplete)
IntControl (73, 1, 0, 0, 0) ; Goto wberrorhandler upon errors.

intPercentComplete = Int (fltPercentComplete) ; Make sure percent is an integer.

strMargin = StrFill (" ", 8)
strBar1 = strMargin : StrFill ("_", 50) : @LF
strBar2 = strMargin : StrFill ("", intPercentComplete) : @LF
strBar3 = strMargin : StrFill ("¯", 50) : @LF
strBar4 = StrFill (" ", 56) : intPercentComplete : "%%"

strMsgText = strMsgText1 : @LF : strMsgText2 : @LF : strMsgText3 : @LF : @LF : strBar1 : strBar2 : strBar3 : strBar4
BoxOpen (strMsgTitle, strMsgText)
Return @TRUE

:WBERRORHANDLER
Return @FALSE
#EndFunction
;-----------------------------------------------------------------------------------------------------------------------


;-----------------------------------------------------------------------------------------------------------------------
#DefineFunction udfBoxProgressUpdate (strMsgText1, strMsgText2, strMsgText3, fltPercentComplete)
IntControl (73, 1, 0, 0, 0) ; Goto wberrorhandler upon errors.

intPercentComplete = Int (fltPercentComplete) ; Make sure percent is an integer.

strMargin = StrFill (" ", 8)
strBar1 = strMargin : StrFill ("_", 50) : @LF
strBar2 = strMargin : StrFill ("", intPercentComplete) : @LF
strBar3 = strMargin : StrFill ("¯", 50) : @LF
strBar4 = StrFill (" ", 56) : intPercentComplete : "%%"

strMsgText = strMsgText1 : @LF : strMsgText2 : @LF : strMsgText3 : @LF : @LF : strBar1 : strBar2 : strBar3 : strBar4
BoxText (strMsgText)
Return @TRUE

:WBERRORHANDLER
Return @FALSE
#EndFunction
;-----------------------------------------------------------------------------------------------------------------------
;=======================================================================================================================
Return ; from GoSub DEFINE_FUNCTIONS
;=======================================================================================================================