home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / database / techs.zip / TECH2.ARC / BARGRAPH.PRG next >
Text File  |  1985-11-01  |  3KB  |  94 lines

  1. * Program..: Bargraph.PRG
  2. * Author...: Brian Evans
  3. * Date.....: August 1, 1985
  4. * Version..: dBASE II, 2.4 and above
  5. * Note(s)..: This program generates a bar graph of monthly
  6. *            accounts receivable and accounts payable data for a
  7. *            fiscal year from Accounts.DBF.  
  8. ERASE
  9. SET TALK OFF
  10. * ---Create axes.
  11. STORE CHR( 196 ) TO x
  12. STORE CHR( 179 ) TO y
  13. STORE 1 TO counter
  14. * ---Generate y-axis border and labels (amounts in 100s).
  15. DO WHILE counter <= 14
  16.    IF INT( counter/3.0 ) = counter/3
  17.       @ counter + 3,6 SAY STR( ( 5 - counter/3 ),1 )+"00";
  18.                           + CHR( 180 )
  19.    ELSE
  20.       @ counter + 3,10 SAY y
  21.    ENDIF
  22.    STORE counter + 1 TO counter
  23. ENDDO
  24. * ---Generate x-axis border and labels (months).
  25. @ 18,10 SAY CHR( 192 )
  26. STORE 1 TO counter
  27. DO WHILE counter <= 61
  28.    STORE INT( counter/5 ) TO mthcnt
  29.    STORE "JanFebMarAprMayJunJulAugSepOctNovDec" TO allmonth
  30.    STORE $( allmonth, ( mthcnt - 1 ) * 3 + 1, 3 ) TO mth
  31.    IF INT( counter/5.0 ) = counter/5
  32.       @ 18,10 + counter SAY CHR( 194 )
  33.       @ 19, 9 + counter SAY mth
  34.    ELSE
  35.       @ 18,10 + counter SAY x
  36.    ENDIF
  37.    STORE counter + 1 TO counter
  38. ENDDO
  39. USE Accounts
  40. STORE 0 TO sumrec
  41. STORE 0 TO sumpay
  42. STORE 1 TO counter
  43. DO WHILE counter <= 12
  44.    * ---Set up simulated arrays for assigning monthly
  45.    * ---accounts receivable (rec1-rec12), and accounts
  46.    * ---payable (pay1-pay2).
  47.    IF counter < 10
  48.       STORE "rec" + STR( counter,1 ) TO rec
  49.       STORE "pay" + STR( counter,1 ) TO pay
  50.    ELSE
  51.       STORE "rec" + STR( counter,2 ) TO rec
  52.       STORE "pay" + STR( counter,2 ) TO pay
  53.    ENDIF
  54.    * ---Assign monthly totals to the appropriate variable.
  55.    SUM Amount TO &rec FOR !( Accttype ) = "R" .AND. Month = counter
  56.    SUM Amount TO &pay FOR !( Accttype ) = "P" .AND. Month = counter
  57.    STORE counter + 1 TO counter
  58. ENDDO
  59. * ---Draw the bars.
  60. STORE 1 TO counter
  61. DO WHILE counter <= 12
  62.    * ---Choose the correct array variable for the
  63.    * ---monthly accounts payable and receivable.
  64.    IF counter < 10
  65.       STORE "rec" + STR( counter,1 ) TO rec
  66.       STORE "pay" + STR( counter,1 ) TO pay
  67.    ELSE
  68.       STORE "rec" + STR( counter,2 ) TO rec
  69.       STORE "pay" + STR( counter,2 ) TO pay
  70.    ENDIF
  71.    * ---Round variables to fit into screen and graph value
  72.    * ---limitations.
  73.    STORE INT( ( &pay/500 ) * 16 ) TO &pay
  74.    STORE INT( ( &rec/500 ) * 16 ) TO &rec
  75.    * ---Draw the accounts payable bar.
  76.    STORE 1 TO upline
  77.    DO WHILE upline <= &pay
  78.       @ 18 - upline,10 + ( counter * 5 ) SAY CHR( 177 )
  79.       STORE upline + 1 TO upline
  80.    ENDDO
  81.    * ---Draw the accounts receivable bar.
  82.    STORE 1 TO upline
  83.    DO WHILE upline <= &rec
  84.       @ 18 - upline,11 + ( counter * 5 ) SAY CHR( 176 )
  85.       STORE upline + 1 TO upline
  86.    ENDDO
  87.    STORE counter + 1 TO counter
  88. ENDDO
  89. * ---Add screen information to complete graph picture.
  90. @ 21,31 SAY "YEARLY ACCOUNTS"
  91. @  1,45 SAY CHR( 177 ) + " = accounts payable"
  92. @  3,45 SAY CHR( 176 ) + " = accounts receivable"
  93. CLEAR
  94. * EOP Bargraph.PRG