In order for this site to work correctly, and for us to improve the site, we need to store a small file (called a cookie) on your computer.
By continuing to use this website, you agree to our cookies and privacy policy.
  
Home page Home page Home page Home page
Pixel
Pixel Header R1 C1 Pixel
Pixel Header R2 C1 Pixel
Pixel Header R3 C1 Pixel
Pixel

Gas Bar

They say that imitation is the sincerest form of flattery so the chaps at RevTech ought to be pleased by the following program. One of the features that I found the most visually appealing in Release 1.1 was what was euphemistically described as the "Gasometer" on the status line when SELECTS or SORTS were in progress. (Obviously the Americans have never lived next door to a British Gasometer). Naturally I wanted to copy this in my own programs but got a little tired of always rewriting the same code, so on the next page please find a listing for a routine that I've called "GAS.BAR" (please, call it what you will). This emulates the functionality of the AREV gasometer but can be used from ANY program which sets @REC.COUNT and then loops through processing each record in the select list. It would be a simple mod to make the program accept a passed record count if @REC.COUNT was not set but I'm trying to keep all code listings to a minimum so I'll leave that to you.

To use, simply enter the program, compile and catalogue it. Then at the top of your program declare subroutine GAS.BAR and within your READNEXT loop, insert the statement GAS.BAR(). E.G.


0001            EQU  TRUE$          TO 1
0002            EQU  FALSE$    TO 0
0003            EOF = FALSE$
0004            DECLARE SUBROUTINE GAS.BAR
0005            PERFORM "SELECT MYFILE"
0006            LOOP
0007                READNEXT ID ELSE EOF = TRUE$
0008            UNTIL EOF DO
0009                GOSUB RECORD.PROCESSING
0010                GAS.BAR()
0011            REPEAT

And so, to the code dissection -

0013  Labelled Common. I'm amazed at how many people don't use labelled
      common. It's very straightforward and well documented in the Technical
      Reference Manual (q.v.)

0014  The Equate statements are used here for two reasons - to improve the
      readability, and in this case to save space further down to prevent
      lines  "wrapping" which becomes misleading

0024  @RN.COUNTER is automatically incremented by the READNEXT processor to
      tell you how far through the select list you are. It is the
      responsibility of the developer to reset this to 0/1 at the start of
      a READNEXT operation.

0049 This test is done to ensure that the Status line is only refreshed when
     the PERCENT done has actually changed. Why waste time refreshing the
     status line with the same value?

NB This routine adds about 3 seconds to the processing of 1000 records, or about .003 seconds per record - a speed sacrifice well worth it for "user friendliness".


0001  SUBROUTINE GAS.BAR
0002  *
0003  *    Author    AMcA
0004  *    Purpose   To display a "Gas Bar" on status line when
0005  *    processing records to indicate progress
0006  *    like in the AREV "Select" process.
0007  *    Copyright Sprezzatura Ltd 1989
0008  *    Permission is granted for REVMEDIA
0009  *    subscribers to use this program for
0010  *    any purpose.  (At your own risk!)
0011  
0012  $INSERT BP,STATUS.CONSTANTS
0013  COMMON/%%GAS.BAR%%/LAST.PERCENT,SAVED.STATUS
0014  EQU VERT$ TO CHAR(170)
0015  EQU BLOCK$     TO CHAR(219)
0016  
0017       IF @REC.COUNT THEN
0018            IF LAST.PERCENT = "" THEN
0019                 *
0020                 * 1st time in, save status line and set LAST.PERCENT
0021                 *
0022                 STATUP(PUSH$,"",SAVED.STATUS)
0023                 LAST.PERCENT = 0
0024                 @RN.COUNTER = 1
0025                 GOSUB DISPLAY.BAR
0026            END ELSE
0027                 *
0028                 * Must be in loop so determine display action
0029                 *
0030                 IF @RN.COUNTER = @REC.COUNT THEN
0031                      *
0032                      *Loop done, remove display and reset stat line
0033                      *
0034                      STATUP(SINGLE$,3,SPACE(62))
0035                      STATUP(POP$,"",SAVED.STATUS)
0036                      LAST.PERCENT = "" ; SAVED.STATUS = ""
0037                 END ELSE
0038                      GOSUB DISPLAY.BAR
0039                 END
0040            END
0041       END ELSE
0042            LAST.PERCENT = "";SAVED.STATUS =""
0043       END
0044  RETURN
0045  
0046  DISPLAY.BAR:
0047       RC= @REC.COUNT ; * done to fit next line on single line
0048       PERCENT = INT((@RN.COUNTER)/RC) * 100)
0049       IF PERCENT # LAST.PERCENT THEN
0050            GRAPH :="Done" : VERT$ : PERCENT "R(0)#3" : "%": VERT$
0051            GRAPH := STR(BLOCK@,INT(PERCENT/2))
0052            STATUP(SINGLE$,3,GRAPH)
0053            LAST.PERCENT = PERCENT
0054       END
0055  RETURN

(Volume 1, Issue 2, Pages 10,11)
Pixel
Pixel Footer R1 C1 Pixel
Pixel
Pixel
Pixel