#!/bin/sh # # This is a shell archive. To extract its contents, # execute this file with /bin/sh to create the file(s): # # progress.4gl progress.txt # # This shell archive created: Thu Aug 6 09:00:56 CDT 1998 # echo "Extracting file progress.txt" sed -e 's/^X//' <<\SHAR_EOF > progress.txt XName & description: X progress.4gl -- job progress bar for Informix 4GL XAuthor: X Jan Kaluza XOk. No fancy packaging, scripts or heavy licence agreements. You are free Xto use this code in your system with only the following two reservations: X1. The code is supplied as-is and the author will in no way be liable for X any damages or data loss whatsoever. Also, I have no control over how X you use this code, so it then becomes *your* problem. X2. Give credit where credit is due. I do recommend you leave the original X file 'progress.4gl' as you received it. It has been tested thoroughly X in a live environment for nearly a year. Please do not remove my name X from the file! XThe above is not too much to ask, I hope. Implementation should be simple Xas the idea and code are simple. Anyone with even rudimentary 4GL should Xbe able to link this in and use it, so I'm not offering any support. XIf you find this program/module useful or you have an idea or suggestion, Xlet me know. J.Kaluza 1998 SHAR_EOF if [ `wc -c < progress.txt` -ne 1074 ] then echo "Lengths do not match -- Bad Copy of progress.txt" fi echo "Extracting file progress.4gl" sed -e 's/^X//' <<\SHAR_EOF > progress.4gl X######################## X# MODULE : progress.4gl X# PURPOSE: to provide a progress bar in 4GL X# AUTHOR : Jan Kaluza X# HISTORY: Version 1.00 .............. 20 November 1997 X# Release 1.01 .............. 17 February 1998 X######################## X X#----------------# X# pseudo globals # X#----------------# XDEFINE st_tim, cr_tim DATETIME DAY TO SECOND XDEFINE el_tim, et_tim INTERVAL DAY TO SECOND XDEFINE mx_bar, barx, bary INTEGER XDEFINE bartxt CHAR(80) X X{ X#------------------------------------------------------------# X# This is a TEST main function -- comment out for live usage # X#------------------------------------------------------------# XMAIN X DEFINE rw,x,big,j,stp INTEGER X DEFINE cchar CHAR X DEFINE progstr CHAR(30) X X WHENEVER ERROR CONTINUE X IF NUM_ARGS() < 2 THEN X LET progstr = ARG_VAL(0) X DISPLAY "Usage: ", progstr CLIPPED, " big_number step" X EXIT PROGRAM X ELSE X LET big = ARG_VAL(1) X LET stp = ARG_VAL(2) X IF big < 2000 THEN LET big = 2000 END IF X IF big > 2000000 THEN LET big = 2000000 END IF X IF stp < 1 THEN LET stp = 1 END IF X IF stp > 200 THEN LET stp = 200 END IF X END IF X DISPLAY "This sample program illustrates the usage of the progress" AT 3,2 X DISPLAY "bar functions in tracking a large task. The purpose of the" AT 4,2 X DISPLAY "functions is to allow the programmer to show the user how" AT 5,2 X DISPLAY "far the task has progressed and also how long the process" AT 6,2 X DISPLAY "has an will still take in terms of time." AT 7,2 X DISPLAY "Required info: current counter, maximum counter value" AT 8,2 X DISPLAY " two open lines on the screen" AT 9,2 X DISPLAY "Usage in your INFORMIX 4GL code:" AT 14,2 X DISPLAY "DEFINE currnt, t_total, done_percent INTEGER" AT 15,2 X DISPLAY " SELECT COUNT(*) INTO t_total FROM xxx" AT 16,2 X DISPLAY " CALL bar_init(row, column, bar_length)" AT 17,2 X DISPLAY " FOREACH xyz INTO xxyyzz" AT 18,2 X DISPLAY " LET currnt = currnt + 1" AT 19,2 X DISPLAY " LET done_percent = bar_work(currnt,t_total,'#')" AT 20,2 X DISPLAY " END FOREACH" AT 21,2 X DISPLAY " CALL bar_term()" AT 22,2 X DISPLAY "...and don't forget to compile in progress.4go !!" AT 23,2 X LET progstr = "0123456789!" -- just being fancy! X CALL bar_init(11,10,50) -- initialize the bar at 15,10 length 50 X LET j = 0 X LET cchar = progstr[j+1] X FOR x = 1 TO big X IF (x MOD stp)=0 THEN -- this example only displays every 'stp' X LET j = bar_work(x,big,cchar) X LET cchar = progstr[(j/10)+1] X SLEEP 1 X END IF X END FOR X CALL bar_term() -- close down the progress bar XEND MAIN X} X X#------------------------------------------------------------------# X# bar_init(r,c,l) - should be called first to initialize variables # X#------------------------------------------------------------------# XFUNCTION bar_init(r,c,l) X DEFINE r,c,l,z INTEGER X LET mx_bar = l X IF mx_bar < 35 THEN LET mx_bar = 35 END IF X IF mx_bar > 70 THEN LET mx_bar = 70 END IF X LET barx = c X IF (barx+mx_bar+8) > 79 THEN LET barx = 72 - mx_bar END IF X IF (barx < 1) THEN LET barx = 1 END IF X LET bary = r X IF bary < 1 THEN LET bary = 1 END IF X IF bary > 22 THEN LET bary = 22 END IF X LET st_tim = EXTEND(CURRENT, DAY TO SECOND) X LET z = bar_work(0,100,'*') XEND FUNCTION -- bar_init(r,c,l) X X#------------------------------------------------------------------# X# bar_work(cr,mx,ch) - called regularly with current, max and char # X#------------------------------------------------------------------# XFUNCTION bar_work(cr,mx,ch) X DEFINE cr,mx INTEGER X DEFINE ch CHAR X DEFINE pcb,pc FLOAT X DEFINE i INTEGER X LET pcb = (cr * 100.0) / mx X LET pc = (cr * mx_bar) / mx X LET bartxt = pcb USING "##&.&%"," :" X LET cr_tim = EXTEND(CURRENT, DAY TO SECOND) X LET el_tim = cr_tim - st_tim X # now the tricky bit: projection! X IF pcb = 0 THEN X LET et_tim = el_tim * 100.0 X ELSE X LET et_tim = (el_tim * 100.0) / pcb X END IF X LET i = bary + 1 X DISPLAY cr,"/",mx," Run:",el_tim," Est:",et_tim," " AT i,barx X LET i = 0 X WHILE (i < pc) X LET bartxt = bartxt CLIPPED, ch X LET i = i + 1 X END WHILE X WHILE (i < mx_bar) X LET bartxt = bartxt CLIPPED, "_" X LET i = i + 1 X END WHILE X DISPLAY bartxt CLIPPED AT bary,barx X RETURN pcb XEND FUNCTION -- bar_work(cr,mx,ch) X X#--------------------------------------------------------------# X# bar_term() - terminates the bar, call optionally to clean up # X#--------------------------------------------------------------# XFUNCTION bar_term() X DEFINE jj,cc,r1,r2 INTEGER X FOR jj = 0 TO (mx_bar+8) X LET cc = barx + jj X LET r1 = bary X LET r2 = bary + 1 X DISPLAY " " AT r1,cc X DISPLAY " " AT r2,cc X END FOR XEND FUNCTION -- bar_term() SHAR_EOF if [ `wc -c < progress.4gl` -ne 4732 ] then echo "Lengths do not match -- Bad Copy of progress.4gl" fi echo "Done." exit 0