%%s 0/0/0 %%d D 1.1 25-Mar-82 12:01:59 v1.1 1 0 %%c Version 1.1 is the Spring 1982 Distribution of the LBL/Hughes release %%c of the Software Tools Virtual Operating System software and documentation. %%T %%I 1 #-h- cbar 686 asc 25-mar-82 07:21:45 v1.1 (sw-tools v1.1) ### CBar Common block for BarGraph flags. common / cbar / dohdr, domean, dosum, dowide, hirule, lorule, barchr, hifill, lofill, meachr, rulchr integer dohdr # YES => Output column headers integer domean # YES => Display mean as a line on the graph integer dosum # YES => Do summation integer dowide # YES => Use 132 columns integer hirule # YES => Apply ruling to space above graph integer lorule # YES => Apply ruling to space below graph character barchr # The bargraph character character hifill # The fill character (over the bar) character lofill # The fill character (under the bar) character meachr # Character for mean, if displayed character rulchr # The ruling character #-h- bargraph.r 5685 asc 25-mar-82 07:21:50 v1.1 (sw-tools v1.1) #-h- defns 174 asc 25-mar-82 07:21:22 v1.1 (sw-tools v1.1) ### Defns Definitions for BarGraph define(BAR_CHAR,'|') define(BAR_STR_SIZE,134) define(DEFAULT_MAX_COL,51) define(TABLE_SIZE,1000) define(MAX_NAME,16) define(MAX_DIGITS,7) #-h- bargraph 3423 asc 25-mar-82 07:21:23 v1.1 (sw-tools v1.1) ### BarGraph Draw a simple 0-100% bar graph for integer data. DRIVER(bargraph) character buf(MAXLINE), name(MAX_NAME,TABLE_SIZE), valstr(MAX_DIGITS) character arg(MAXARG), barstr(BAR_STR_SIZE), c filedes fd filedes open # function(s) integer maxcol, mean, sum, value(TABLE_SIZE) integer i, j, junk, maxval, maxndx, minval, ndx, percen, range integer ctoi, getarg, getlin, getwrd # function(s) include cbar data barchr /BAR_CHAR/ data hifill /' '/ data lofill /BAR_CHAR/ data meachr /'.'/ data rulchr /':'/ data dohdr /NO/ # Default == No header. data dosum /NO/ # Default == No Summation. data dowide /NO/ # Default == 80 columns vs. 132. data hirule /NO/ # Default == No ruling above graph. data lorule /NO/ # Default == No ruling below graph. data maxcol /DEFAULT_MAX_COL/ # Default scaling is 2 % per char. data maxval /0/ data minval /0/ data range /0/ data sum /0/ call query("usage: bargraph [-cfFhmrRsw] [file] ...") call bararg # Process args if( dowide == YES ) maxcol = maxcol + 50 if( dohdr == YES ) # Output column headers. call barhdr(dowide) ndx = 1 for( j = 1 ; ; j = j + 1 ) { if( getarg( j, arg, MAXARG) == EOF ) { if( j != 1 ) break else fd = STDIN } else { if( arg(1) == '-' ) fd = STDIN else { fd = open( arg, READ) if( fd == ERR ) call cant(arg) } } for( ; getlin( buf, fd) != EOF ; ndx = ndx + 1 ) { maxndx = ndx if( ndx > TABLE_SIZE ) { call remark( "? Too much data: increase TABLE_SIZE." ) break } i = 1 junk = getwrd( buf, i, name( 1, ndx)) # Store name junk = getwrd( buf, i, valstr) # Get value i = 1 value(ndx) = ctoi( valstr, i) # Convert to int. & store if( dosum == NO ) { if( value(ndx) > maxval ) # Check for new max maxval = value(ndx) if( value(ndx) < minval ) # Check for new min minval = value(ndx) } range = range + value(ndx) # Accumulate } if( fd != STDIN ) call close(fd) } if( ndx > 1 & dosum == NO ) mean = range / (ndx - 1) else mean = 0 if( dosum == NO ) { range = maxval - minval if( range == 0 ) call error( "? Range of data values is 0." ) } for( ndx = 1 ; ndx <= maxndx ; ndx = ndx + 1 ) { call putstr( name( 1, ndx), -MAX_NAME, STDOUT) call putint( value(ndx), MAX_DIGITS, STDOUT) call putch( ' ', STDOUT) if( dosum == YES ) { sum = sum + value(ndx) percen = ( sum * 100 ) / range } else percen = ( value(ndx) * 100 ) / range call putch( '|', STDOUT) if( dowide == NO ) percen = percen / 2 for( i = 1 ; i < percen ; i = i + 1 ) { barstr(i) = lofill if( lorule == YES ) if( dowide == YES ) { if( mod( i, 10) == 0 ) barstr(i) = rulchr } else if( mod( i, 5) == 0 ) barstr(i) = rulchr } call chcopy( barchr, barstr, i) for( ; i < maxcol ; i = i + 1 ) { barstr(i) = hifill if( hirule == YES ) if( dowide == YES ) { if( mod( i, 10) == 0 ) barstr(i) = rulchr } else if( mod( i, 5) == 0 ) barstr(i) = rulchr } if( domean == YES & mean > 0 ) { if( dowide == YES ) barstr( mean * 100 / range ) = meachr else barstr( mean * 50 / range ) = meachr } barstr(i) = '|' barstr(i+1) = EOS call putlin( barstr, STDOUT) call putch( '@n', STDOUT) } DRETURN end #-h- bararg 1310 asc 25-mar-82 07:21:25 v1.1 (sw-tools v1.1) ### BarArg Process argument flags for BarGraph. subroutine bararg include cbar character arg(MAXARG), c integer i integer getarg # function(s) for( i = 1 ; getarg( i, arg, MAXARG) != EOF ; i = i + 1 ) { if( arg(1) == '-' ) { c = arg(2) if( c == EOS ) # Leave bare '-' intact next if( c == 'c' ) # Change bar character. { if( arg(3) > ' ' ) # Make sure it's visible. barchr = arg(3) } else if( c == 'f' ) # Change lofill character. { if( arg(3) >= ' ' ) # Visible or ' '. lofill = arg(3) } else if( c == 'F' ) # Change hifill character. { if( arg(3) > ' ' ) # Visible or ' '. hifill = arg(3) } else if( c == 'h' ) # Do column headers. dohdr = YES else if( c == 'm' ) # Display mean. { domean = YES if( arg(3) >= ' ' ) meachr = arg(3) } else if( c == 'r' ) # Do ``lo'' ruling. { lorule = YES if( arg(3) > ' ' ) rulchr = arg(3) } else if( c == 'R' ) # Do ``hi'' ruling. { hirule = YES if( arg(3) > ' ' ) rulchr = arg(3) } else if( c == 's' ) # Do summation. dosum = YES else if( c == 'w' ) # Do Wide(132-column) mode. dowide = YES call delarg(i) i = i - 1 } } return end #-h- barhdr 486 asc 25-mar-82 07:21:25 v1.1 (sw-tools v1.1) ### BarHdr Output column headers for BarGraph. subroutine barhdr(dowide) integer dowide, i string hdrstr "Name Size " string blanks " " # 8 of them. string hundrd "100" if( dowide == NO ) blanks(4) = EOS # Shorten string to 3 BLANKs. call putlin( hdrstr, STDOUT) for( i = 0 ; i < 100 ; i = i + 10 ) { call putint( i, 1, STDOUT) call putlin( blanks, STDOUT) } call putlin( hundrd, STDOUT) call putch( '@n', STDOUT) call putch( '@n', STDOUT) return end #-h- bargraph.fmt 1962 asc 25-mar-82 07:21:53 v1.1 (sw-tools v1.1) .so ~bin/manhdr .hd BarGraph (1) 11-Nov-81 draw a 0-100% bargraph of integer data .sy bargraph -[cfFhmrRsw] file ... .ds BarGraph draws a simple graph of integer data scaled to 0-100%. Each line of input is expected to contain two fields, a label and a number, both in ASCII. The label and its associated numeric value should be separated by one or more BLANKs or a TAB. There are several options for controlling the appearance of the graph: .sp .in +10 .ti -6 -c use as the character for plotting the ordinate instead of ``|'' (the default) .sp .ti -6 -f use to fill the area under the bar .sp .ti -6 -F use to fill the area over the bar .sp .ti -6 -h output column headers .sp .ti -6 -m[c] display the mean of the data, using ``c'' if specified instead of ``.'' (the default) .sp .ti -6 -r[c] display ruling every 10% under the bar, using ``c'' if specified instead of ``:'' (the default) .sp .ti -6 -R[c] display ruling every 10% over the bar, using ``c'' if specified instead of ``:'' (the default) .sp .ti -6 -s plot the running sum of the data values rather than the values themselves .sp .ti -6 -w make the graph 132 columns wide rather than 80 .in -10 .ex .ce bargraph -h -f* -w file .sp .fi would make a 132-column wide graph of the data in ``file'', with column headers and ``*'' characters filling under the bar. .sp .ce d "-f16n 9c" | bargraph "-f|" .sp would graph the sizes of all files in the current directory using ``|'' as the fill character below the bar. Note that it is necessary to put quotes around character specification options when specifying characters that are special to the shell (the "-f|" in the above example). .fl none .sa .di ? Too much data: increase TABLE_SIZE .au Dave Martin (Hughes Aircraft) .bu There is an upper limit to the number of points which may be graphed. This limit may be raised by increasing the value of TABLE_SIZE. Numeric values are currently limited to 7 digits or less. %%E 1