%%HP: T(3)A(D)F(.);
@  Progress Bar - By Stanley H. Lui 4/27/03
@
@ This GUI utility displays a progress bar.
@ Input:  x  y  dx  ci  maxi bg
@  x - upper x coordinate of the progress bar
@  y - upper y coordinate of the progress bar
@ dx - length of the progress bar
@ ci - current progress bar value
@ maxi - maximum progress bar value
@ bg - background grob to be redrawn at the end of the progress bar display
@ 
@ output: bg
@  bg:  the back ground grob underneath is returned.
@
@ Note:  - Progress bar value should start from 1
@           -The progress bar will not be displayed if it is positioned out of
@             the valid grid dimension
@           - The calling routine should store the background grob bg returned to
@             a variable upon return and use it when calling PRSBAR thereafter

\<< 

0

GROB 131 3 FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF70FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF70FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF70

\-> x y dx ci maxi  bg    xs xg \<<

IF x dx + 131 \<=  y 5 + 64 \<= AND THEN
  IF ci 1 == THEN
@   save background grob to be redrawn later
     PICT x R\->B y R\->B 2 \->LIST x dx + 1 - R\->B y 4 + R\->B 2 \->LIST SUB 'bg' STO
@   draw progress bar frame
     x R\->B y R\->B 2 \->LIST x  dx + 1 - R\->B y 4 + R\->B 2 \->LIST BOX
  END
  maxi ci %T 0 RND 100 /  dx 2 - * 0 RND 'xs' STO
  IF xs 0 > THEN
    PICT  x 1 + R\->B y 1 + R\->B 2 \->LIST  xg {#0d #0d}  xs 1 - R\->B #2d 2 \->LIST SUB REPL
  END
  IF ci maxi == THEN
    1 WAIT PICT x R\->B y R\->B 2 \->LIST bg REPL
  END
  
  bg

END

\>>
\>>