home *** CD-ROM | disk | FTP | other *** search
/ Amiga GigaPD 3 / Amiga_GigaPD_v3_3of3.iso / fred_fish / fish_601-700_lha / fish_641.lha / TLOG / monthtot1.tlog < prev    next >
Text File  |  1993-06-02  |  3KB  |  94 lines

  1. /* AREXX report for TLog that prints the total monthly distances */
  2.  
  3. /* Start at the begining of the data base and keep getting the next record */
  4. /* and add up any distances until you get to the end.  Right now the only  */
  5. /* way to tell you're at the end is when nextrec result is lastrec         */
  6.  
  7.  
  8. OPTIONS RESULTS
  9.  
  10. /* setup the port to tlog */
  11. ADDRESS 'TLOG'
  12.  
  13. /* Initialize the a table of monthly totals */
  14. total.JAN = 0;
  15. total.FEB = 0;
  16. total.MAR = 0;
  17. total.APR = 0;
  18. total.MAY = 0;
  19. total.JUN = 0;
  20. total.JUL = 0;
  21. total.AUG = 0;
  22. total.SEP = 0;
  23. total.OCT = 0;
  24. total.NOV = 0;
  25. total.DEC = 0;
  26. total.YEAR = 0;
  27.  
  28. /* use TLog dateformat MMM DD YY and grab the 1st 3 chars as the month */
  29. getdateformat
  30. oldformat = result
  31. dateformat 4
  32.  
  33. /* If you have been making entries into the data base, it is best to */
  34. /* flush its buffers by doing a close first */
  35. 'closedb'
  36.  
  37. /* Open the data base and mark the end record */
  38. 'opendb'
  39. 'lastrec'
  40. lastdatarecord = result
  41.  
  42. /* Here the distance field, dbdist, is added to the running total for the */
  43. /* month.  The month is found by extracting a substring of the date field,*/
  44. /* dbdate.  More sophisticated reports can come from this simple example. */
  45. /* For instance, you can filter out (don't add) any distance that comes   */
  46. /* from a record with a particular dbkey, e.g. GOAL, and save them in  a  */
  47. /* different table.  Then print the tables together for comparison.       */
  48.  
  49. /* get the first record and its data */
  50. 'firstrec'
  51. /* the fields are delineated with vericle bars '|' */
  52. PARSE var result '"' dbdate '"' dbheart dbdist dbtime dbweight dbtemp dbkey
  53. month = SUBSTR(dbdate,1,3)
  54. total.month =  total.month + dbdist
  55. total.YEAR =  total.YEAR + dbdist
  56.  
  57. /* Now loop forever, or until nextrec yields the last record */
  58. DO FOREVER
  59.     'nextrec'
  60.     /* the fields are delineated with vericle bars '|' */
  61.     parse var result '"' dbdate '"' dbheart dbdist dbtime dbweight dbtemp dbkey
  62.     month = SUBSTR(dbdate,1,3)
  63.     total.month =  total.month + dbdist
  64.     total.YEAR =  total.YEAR + dbdist
  65.     if  result = lastdatarecord then BREAK
  66. END
  67.  
  68. /* restore the date format */
  69. dateformat oldformat
  70.  
  71.  
  72. /* Now generate your reports; or pass the data to spread sheet or graphics */
  73. /* program that has an AREXX interface.  You might even have scripts that  */
  74. /* do bar charts in AREXX already.    For now we'll keep it simple ...     */
  75.  
  76. /* print out our monthly totals */
  77.  
  78. say "Total distances by month:"
  79. say JAN total.JAN
  80. say FEB total.FEB
  81. say MAR total.MAR
  82. say APR total.APR
  83. say MAY total.MAY
  84. say JUN total.JUN
  85. say JUL total.JUL
  86. say AUG total.AUG
  87. say SEP total.SEP
  88. say OCT total.OCT
  89. say NOV total.NOV
  90. say DEC total.DEC
  91. say"---------"
  92. say "TOT" total.YEAR
  93.  
  94.