|
PROGRES PowerBASIC Routine |
|
PROGRES routine displays processing progress indicator and is intended for use in the file processing procedures (external executables started from the Windows command prompt) having a relatively short running time (about 1 minute). For the longer running procedures the PROGRTM routine (with the elapsed/left time display) might be more appropriate. Debugging program provides an example of the PROGRES routine usage with the three characteristic CALL lines (color-coded):
If you'll choose to set your own progress symbols, any decent text editor (including PowerBASIC IDE) would provide you with the table of all symbols to choose from. Color codes (PROGRES.BAS needs them in hex) can be found in the COLOR command description of PowerBASIC IDE.
PROGRES Source Program Debugging program Debugging logout |
' PROGRES(2.1) Display File Process Progress Indicator 06/27/1994-02/15/2010
' ------------------------------------------------------------------------------
' Copyright (C) 1994-2010 by Vladimir Veytsel www.davar.net
' Type -------------------------------------------------------------------------
' Routine
' Parameters -------------------------------------------------------------------
' File% - File number (as it was opened in calling program)
' Nam$ - Program name and version (E.g.: "CONVERT(0.0)")
' Title$ - Process title string (truncated to 64 chars if longer)
' Record$ - Current input record
' Mode$ - Progress indicator display mode:
' S - Start
' P - Progress
' F - Finish (any value different from "S" or "P" is equivalent to "F")
' Appear$ - Appearance control string (fixed structure 6-character):
' +------- Incomplete symbol (Default: ">")
' |+------ Complete symbol (Default: "=")
' ||+----- Incomplete color attribute (Default: "E" - Yellow)
' |||+---- Complete color attribute (Default: "B" - Bright Cayan)
' ||||+--- Running color attribute (Default: "A" - Bright Green)
' |||||+-- Background color attribute (Default: "0" - Black)
' ||||||
' 123456
' >=EBA0 - Default appearance control string (padded with blanks)
' Individual blanks default to corresponding symbols
' Note: This parameter is processed only in "Start" mode
' (in "Progress" and "Finish" mode it is ignored)
' Notes ------------------------------------------------------------------------
' - Routine is intended for use in file processing/conversion procedures
' running from command prompt and showing processing progress on a screen.
' - Use it with short running (about 1 minute) procedures.
' - For long procedures see routine PROGRTM (with elapsed/left time display).
' - Rotating indicator wheel is synchronized with completeness % display.
' Examples ---------------------------------------------------------------------
' Start: CALL PROGRES(1,"CONVERT(0.0)","File...","","S",">=EBA0") - After OPEN
' CONVERT(0.0) File SOURCE.TXT is converted to TARGET.TXT
' 0% [-] >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
' Progress: CALL PROGRES(1,"","",Input.Record$,"P","") - After every LINE INPUT
' CONVERT(0.0) File SOURCE.TXT is converted to TARGET.TXT
' 50% [|] =====================>>>>>>>>>>>>>>>>>>>>>
' Finish: CALL PROGRES(1,"","","","F","") - After encountering EOF
' CONVERT(0.0) File SOURCE.TXT is converted to TARGET.TXT
' 100% [*] ==========================================
' Start Routine ----------------------------------------------------------------
DEFINT A-Z ' All defaulted variables are integer
SUB PROGRES(File%,Nam$,Title$,Record$,Mode$,Appear$) STATIC
DIM Wheel$(4)
' Initialize Routine Constants (Start) -----------------------------------------
SELECT CASE (UCASE$(Mode$))
CASE ("S")
Wheel$(1)="-"
Wheel$(2)="\"
Wheel$(3)="|"
Wheel$(4)="/"
IF (LEN(Appear$)=0) THEN
App$=">=EBA0"
ELSE
App$=Appear$+" "
END IF
Incompl_Symb$ =MID$(App$,1,1)
Complete_Symb$ =MID$(App$,2,1)
Incompl_Color$ =MID$(App$,3,1)
Complete_Color$ =MID$(App$,4,1)
Running_Color$ =MID$(App$,5,1)
Background_Color$=MID$(App$,6,1)
IF (Incompl_Symb$ =" ") THEN Incompl_Symb$ =">"
IF (Complete_Symb$ =" ") THEN Complete_Symb$ ="="
IF (Incompl_Color$ =" ") THEN Incompl_Color$ ="E"
IF (Complete_Color$ =" ") THEN Complete_Color$ ="B"
IF (Running_Color$ =" ") THEN Running_Color$ ="A"
IF (Background_Color$=" ") THEN Background_Color$="0"
Incompl_Color =VAL("&H"+Incompl_Color$)
Complete_Color =VAL("&H"+Complete_Color$)
Running_Color =VAL("&H"+Running_Color$)
Background_Color=VAL("&H"+Background_Color$)
' Display Initial Processing Progress Message ----------------------------------
File_Size!=LOF(File%) ' Get input file size
CONSOLE GET SCREEN TO Rows&,Columns&
Max_Title_Len=Columns&-LEN(Nam$)-2
IF (LEN(Title$)>Max_Title_Len) THEN Title$=LEFT$(Title$,Max_Title_Len)
Title_Len=LEN(Title$)
Percent_Pos=LEN(Nam$)-8
Time_Pos=LEN(Nam$)+LEN(Title$)+5
Share!=File_Size!/Title_Len
IF (Share!=0) THEN Share!=1
Limit!=Share!
COLOR Complete_Color,Background_Color
PRINT Nam$;" ";Title$
PRINT TAB(Percent_Pos);" 0% [";Wheel$(1);"] ";
COLOR Incompl_Color,Background_Color
PRINT STRING$(Title_Len,Incompl_Symb$);
Length_Ratio!=Title_Len/File_Size!
Curs_Line=CSRLIN
' Redisplay Processing Progress Message ----------------------------------------
CASE ("P")
Curr_Size!=Curr_Size!+LEN(Record$)+2
Percent_Compl=Curr_Size!/File_Size!*100
LOCATE ,Percent_Pos
COLOR Running_Color,Background_Color
PRINT USING$("###",Percent_Compl);
PRINT "% [";Wheel$((Percent_Compl MOD 4)+1);"] ";
IF (Curr_Size!>Limit!) THEN
COLOR Complete_Color,Background_Color
PRINT STRING$(Curr_Size!*Length_Ratio!,Complete_Symb$);
Counter=Counter+1
Limit!=Counter*Share!
END IF
' Redisplay Process Finish Message ---------------------------------------------
CASE ELSE
COLOR Complete_Color,Background_Color
LOCATE Curs_Line,Percent_Pos
PRINT "100% [*] ";STRING$(Title_Len,Complete_Symb$)
END SELECT
' Finish Routine ---------------------------------------------------------------
COLOR 7,0 ' Restore Gray on Black
END SUB
|
PROGRES Debugging Program Source program Debugging logout |
' PROGRES(2.1) Display File Process Progress Indicator 06/27/1994-02/13/2010
' ------------------------------------------------------------------------------
#INCLUDE "PROGRES"
FUNCTION PBMAIN
Pause!=10
PRINT "PROGRES(2.1) Display File Processing Progress Indicator ";DATE$;
PRINT " ";LEFT$(TIME$,5)
PRINT STRING$(75,"-")
PRINT
OPEN "C:\PBASIC\PROGRES.BAS" FOR INPUT AS #1
CALL PROGRES(1,"CONVERT(0.0)","File SOURCE.TXT is converted to TARGET.TXT","","S",Appear$)
WHILE (NOT(EOF(1)))
LINE INPUT #1,Input_Record$
CALL PROGRES(1,"","",Input_Record$,"P","")
SLEEP Pause!
WEND
CALL PROGRES(1,"","","","F","")
END FUNCTION
|
PROGRES Debugging Logout Source program Debugging program |
PROGRES(2.1) Display File Processing Progress Indicator 09-18-2016 21:56
---------------------------------------------------------------------------
CONVERT(0.0) File SOURCE.TXT is converted to TARGET.TXT
24% [-] ==========>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
PROGRES(2.1) Display File Processing Progress Indicator 09-18-2016 21:56
---------------------------------------------------------------------------
CONVERT(0.0) File SOURCE.TXT is converted to TARGET.TXT
74% [|] ===============================>>>>>>>>>>>
|
PROGRES(2.1) Display File Processing Progress Indicator 09-18-2016 21:56
---------------------------------------------------------------------------
CONVERT(0.0) File SOURCE.TXT is converted to TARGET.TXT
100% [*] ==========================================
|
|
View [and save] PROGRES.BAS text View [and save] ZPROGRES.BAS text (Use [Back] button or [Alt]+[CL] to return here from the viewed text) Copyright © 1994–2010 by Go to: Davar site entry | Site contents | Site index | Personal Computer | PowerBASIC | Text top |