Progress Bar

The RPG to generate a Progress Bar for source files
      *====================================================================*    
      *          Progress Bar                                              *    
      *--------------------------------------------------------------------*    
      *                                                                    *    
      *  9/00  Booth Martin, created program                               *    
      *                                                                    *    
      *--------------------------------------------------------------------*    
     FUtl4020D  cf   e             WorkStn                                      
      *---------------------------------------------------------------------    
     D TimeStart       S               T                                        
     D TimeNow         S               T                                        
     D TimeHMS         S               T   TimFmt(*HMS)                         
     D TotalSecs       S              9S 0                                      
     D TimeHMSa        S              8                                         
      *                                                                         
     D CurrentRec      S              7S 0                                      
     D TotalRecs       S              7S 0                                      
     D PCT             S              3S 0                                      
                                                                                          
      *                                                                                   
      * play stuff                                                                        
     C                   Eval      TotalRecs = 2000                                       
     C                   Time                    TimeStart                                
                                                                                          
     C                   dow       CurrentRec < TotalRecs                                 
     C                   Eval      CurrentRec = CurrentRec + 1                            
                                                                                          
      * Set the xx% value                                                                 
     C                   EVAL      pct = CurrentRec * 100 / TotalRecs                     
     C                   EVAL      PRGBAR = '     ' +                                     
     C                             %Triml(%EditC(CurrentRec:'3')) +                       
     C                             ' records of ' +                                       
     C                             %Triml(%EditC(TotalRecs:'3')) + ' read.   ' +          
     C                             %EditW(PCT:'   %')                                     
      * Estimated time to completion:  
      *  (Below 5% the estimated time is probably badly misleading) 
     C                   If        Pct > 5                                                
     C                   Time                    TimeNow                                  
      * Time elapsed so far:?                                                             
     C     TimeNow       SubDur    TimeStart     TotalSecs:*S                   
     C                   Eval      TotalSecs = TotalSecs/pct * (100 - pct)      
     C     T'00.00.00'   AddDur    TotalSecs:*S  TimeHMS                        
     C                   MoveL     TimeHMS       Tmp20            20            
     C                   Move      'remaining  ' Tmp20                          
     C                   Move      Tmp20         PrgBar                         
     C                   End                                                    
                                                                                
      * Set the RI placement                                                    
     C*                  EVAL      pct = (CurrentRec * %size(PRGBAR))/TotalRecs 
     C                   EVAL      pct = (CurrentRec * 74)/TotalRecs            
                                                                                
     C                   If        Pct > 0                                      
     C                   EVAL      %subst(PRGBAR:pct:1) = x'21'                 
     C                   Write     FMT01                                        
     C                   End                                                    
                                                                                
     C                   EndDo                                                  
                                                                                
     C                   EVAL      %subst(PRGBAR:74:1) = ' '                    
     C                   Exfmt     FMT01                                        
                                                                                
     C                   eval      *inLR = *on                                  
      * ---------------------------------------------------------------------   








The DDS for the screen format

     A*%%TS  SD  20000914  162243  BMARTIN     REL-V3R7M0  5716-PW1            
     A******************************************************************       
     A*                                                                        
     A*  DISPLAY FILE ID     -    Progress Bar Window                          
     A*  DISPLAY FILE NAME   -                                                 
     A*  DATE CREATED        -    9/00                                         
     A*                                                                        
     A******************************************************************       
     A*%%EC                                                                    
     A                                      DSPSIZ(24 80 *DS3)                 
     A                                      ERRSFL                             
     A          R FMT01                                                        
     A*%%TS  SD  20000914  162243  BMARTIN     REL-V3R7M0  5716-PW1            
     A                                      TEXT('A displayable Progress bar') 
     A                                      OVERLAY                            
     A                                      WINDOW(22 2 1 74 *NOMSGLIN)        
     A            PRGBAR        74   O  1  1DSPATR(RI)                         
     A                                      COLOR(RED)                         
     A          R DUMMY                                                          
     A                                      TEXT('PREVENTS PREVIOUS SCREEN FROM- 
     A                                       BEING CLEARED')                     
     A                                      ASSUME                               
     A                                  1  9' '