home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / parsomat.zip / exampl18.pom < prev    next >
Text File  |  2001-07-15  |  8KB  |  214 lines

  1. ;
  2. ;   Prologue
  3. ;
  4. PROLOGUE
  5.   ;
  6.   ;   Use MINLEN to set READNEXT to ignore null lines in the input
  7.   ;
  8.   MINLEN   "1" "1"
  9.   ;
  10.   ;   Skip the header lines
  11.   ;
  12.   ;   Note that since we're in the PROLOGUE section, the first READNEXT
  13.   ;   actually reads the first line of the input file, since the prologue
  14.   ;   is run before any input lines have been read.
  15.   ;
  16.   READNEXT
  17.   READNEXT
  18.   READNEXT
  19.   READNEXT
  20.   READNEXT
  21.   READNEXT
  22.   READNEXT
  23.   ;
  24.   ;   Output a report header.  We could use the OUTHDG command to do
  25.   ;   this, but it's just as easy to use OUTEND in the PROLOGUE section.
  26.   ;
  27.   ;         ----+----1----+----2----+----3----+----4  (Measuring scale)
  28.   OUTEND   |----------------------------------------
  29.   OUTEND   |          WEEKLY SALES SUMMARY
  30.   OUTEND   |----------------------------------------
  31.   OUTEND   |
  32.   OUTEND   |  DATE       CRATES SOLD      EARNINGS
  33.   OUTEND   |--------     -----------    ------------
  34. END
  35. ;
  36. ;-------------------------------------------------------------------------------
  37. ;
  38. ;   Get the date and initialize the daily figures
  39. ;
  40. ;   We did not have to initialize the accumulating weekly figures in the
  41. ;   prologue, since an unassigned variable is set to null (""), which
  42. ;   the calculation commands treat as zero.
  43. ;
  44. IGNORE   $FLINE[11]   = "-"
  45. DATE     date         "" $FLINE[14 15] $FLINE[17 18] "M ?d"
  46. PAD      date         "C" " " "8"
  47. SET      soldtoday    = "0"
  48. SET      cashtoday    = "0.00"
  49. ;
  50. ;   Read in the day's data
  51. ;
  52. ;   Beans
  53. ;
  54. CALC     soldbeanwkly = soldbeanwkly  "+" $FLINE[50 58]
  55. CALC     soldtoday    = soldtoday     "+" $FLINE[50 58]
  56. CALCREAL cash         = $FLINE[50 58] "*" $FLINE[61 69] "2"
  57. CALCREAL cashbeanwkly = cashbeanwkly  "+" cash          "2"
  58. CALCREAL cashtoday    = cashtoday     "+" cash          "2"
  59. ;
  60. ;   Zucchinis
  61. ;
  62. READNEXT
  63. CALC     soldzuccwkly = soldzuccwkly  "+" $FLINE[50 58]
  64. CALC     soldtoday    = soldtoday     "+" $FLINE[50 58]
  65. CALCREAL cash         = $FLINE[50 58] "*" $FLINE[61 69] "2"
  66. CALCREAL cashzuccwkly = cashzuccwkly  "+" cash          "2"
  67. CALCREAL cashtoday    = cashtoday     "+" cash          "2"
  68. ;
  69. ;   Tomatoes, Type 1
  70. ;
  71. READNEXT
  72. CALC     soldtom1wkly = soldtom1wkly  "+" $FLINE[50 58]
  73. CALC     soldtoday    = soldtoday     "+" $FLINE[50 58]
  74. CALCREAL cash         = $FLINE[50 58] "*" $FLINE[61 69] "2"
  75. CALCREAL cashtom1wkly = cashtom1wkly  "+" cash          "2"
  76. CALCREAL cashtoday    = cashtoday     "+" cash          "2"
  77. ;
  78. ;   Tomatoes, Type 2
  79. ;
  80. READNEXT
  81. CALC     soldtom2wkly = soldtom2wkly  "+" $FLINE[50 58]
  82. CALC     soldtoday    = soldtoday     "+" $FLINE[50 58]
  83. CALCREAL cash         = $FLINE[50 58] "*" $FLINE[61 69] "2"
  84. CALCREAL cashtom2wkly = cashtom2wkly  "+" cash          "2"
  85. CALCREAL cashtoday    = cashtoday     "+" cash          "2"
  86. ;
  87. ;   Corn
  88. ;
  89. READNEXT
  90. CALC     soldcornwkly = soldcornwkly  "+" $FLINE[50 58]
  91. CALC     soldtoday    = soldtoday     "+" $FLINE[50 58]
  92. CALCREAL cash         = $FLINE[50 58] "*" $FLINE[61 69] "2"
  93. CALCREAL cashcornwkly = cashcornwkly  "+" cash          "2"
  94. CALCREAL cashtoday    = cashtoday     "+" cash          "2"
  95. ;
  96. ;   Lettuce
  97. ;
  98. READNEXT
  99. CALC     soldlettwkly = soldlettwkly  "+" $FLINE[50 58]
  100. CALC     soldtoday    = soldtoday     "+" $FLINE[50 58]
  101. CALCREAL cash         = $FLINE[50 58] "*" $FLINE[61 69] "2"
  102. CALCREAL cashlettwkly = cashlettwkly  "+" cash          "2"
  103. CALCREAL cashtoday    = cashtoday     "+" cash          "2"
  104. ;
  105. ;   Accumulate the total weekly figures
  106. ;
  107. CALC     soldwkly     = soldwkly      "+" soldtoday
  108. CALCREAL cashwkly     = cashwkly      "+" cashtoday     "2"
  109. ;
  110. ;   Output the daily figures
  111. ;
  112. PAD      soldtoday "L" " " "12"
  113. PAD      cashtoday "L" " " "11"
  114. OUTEND   |{date}    {soldtoday}    ${cashtoday}
  115. ;
  116. ;-------------------------------------------------------------------------------
  117. ;
  118. ;   Epilogue
  119. ;
  120. ;
  121. EPILOGUE
  122.   ;
  123.   ;   Format figures for output
  124.   ;
  125.   PAD      soldwkly     "L" " " "12"
  126.   PAD      cashwkly     "L" " " "12"
  127.   PAD      soldbeanwkly "L" " " "12"
  128.   PAD      soldzuccwkly "L" " " "12"
  129.   PAD      soldtom1wkly "L" " " "12"
  130.   PAD      soldtom2wkly "L" " " "12"
  131.   PAD      soldcornwkly "L" " " "12"
  132.   PAD      soldlettwkly "L" " " "12"
  133.   PAD      cashbeanwkly "L" " " "12"
  134.   PAD      cashzuccwkly "L" " " "12"
  135.   PAD      cashtom1wkly "L" " " "12"
  136.   PAD      cashtom2wkly "L" " " "12"
  137.   PAD      cashcornwkly "L" " " "12"
  138.   PAD      cashlettwkly "L" " " "12"
  139.   ;
  140.   ;   Calculate averages
  141.   ;
  142.   ;   Note that we do not specify the number of decimal places
  143.   ;   for soldavg, so we will get a "floating point" answer.
  144.   ;
  145.   CALCREAL soldavg  = soldwkly "/" "5"
  146.   CALCREAL cashavg  = cashwkly "/" "5" "2"
  147.   PAD      soldavg  "L" " " "12"
  148.   PAD      cashavg  "L" " " "12"
  149.   ;
  150.   ;   Figure out best-selling and best-earning item
  151.   ;
  152.   CALC     soldbest =  soldbeanwkly    "HIGHEST"     soldzuccwkly
  153.   IF       soldbest #< soldtom1wkly THEN soldbest  = soldtom1wkly
  154.   IF       soldbest #< soldtom2wkly THEN soldbest  = soldtom2wkly
  155.   IF       soldbest #< soldcornwkly THEN soldbest  = soldcornwkly
  156.   IF       soldbest #< soldlettwkly THEN soldbest  = soldlettwkly
  157.   PAD      soldbest "L" " " "12"
  158.  
  159.   CALCREAL cashbest =  cashbeanwkly    "HIGHEST"     cashzuccwkly "2"
  160.   IF       cashbest #< cashtom1wkly THEN cashbest  = cashtom1wkly
  161.   IF       cashbest #< cashtom2wkly THEN cashbest  = cashtom2wkly
  162.   IF       cashbest #< cashcornwkly THEN cashbest  = cashcornwkly
  163.   IF       cashbest #< cashlettwkly THEN cashbest  = cashlettwkly
  164.   PAD      cashbest "L" " " "12"
  165.   ;
  166.   ;   Figure out worst-selling and worst-earning item
  167.   ;
  168.   CALC     soldworst =  soldbeanwkly    "LOWEST"      soldzuccwkly
  169.   IF       soldworst #> soldtom1wkly THEN soldworst = soldtom1wkly
  170.   IF       soldworst #> soldtom2wkly THEN soldworst = soldtom2wkly
  171.   IF       soldworst #> soldcornwkly THEN soldworst = soldcornwkly
  172.   IF       soldworst #> soldlettwkly THEN soldworst = soldlettwkly
  173.   PAD      soldworst "L" " " "12"
  174.  
  175.   CALCREAL cashworst =  cashbeanwkly    "LOWEST"      cashzuccwkly "2"
  176.   IF       cashworst #> cashtom1wkly THEN cashworst = cashtom1wkly
  177.   IF       cashworst #> cashtom2wkly THEN cashworst = cashtom2wkly
  178.   IF       cashworst #> cashcornwkly THEN cashworst = cashcornwkly
  179.   IF       cashworst #> cashlettwkly THEN cashworst = cashlettwkly
  180.   PAD      cashworst "L" " " "12"
  181.   ;
  182.   ;   Output a header (column scale shown below)
  183.   ;
  184.   ;         ----+----1----+----2----+----3----+----4  (Measuring scale)
  185.   OUTEND   |
  186.   OUTEND   |----------------------------------------
  187.   OUTEND   |             WEEKLY FIGURES
  188.   OUTEND   |----------------------------------------
  189.   OUTEND   |
  190.   OUTEND   |CRATES SOLD:       Beans:   {soldbeanwkly}
  191.   OUTEND   |                Zucchini:   {soldzuccwkly}
  192.   OUTEND   |           Tomato Type 1:   {soldtom1wkly}
  193.   OUTEND   |           Tomato Type 2:   {soldtom2wkly}
  194.   OUTEND   |                    Corn:   {soldcornwkly}
  195.   OUTEND   |                 Lettuce:   {soldlettwkly}
  196.   OUTEND   |           --------------   ------------
  197.   OUTEND   |            Weekly Total:   {soldwkly}
  198.   OUTEND   |           Daily Average:   {soldavg}
  199.   OUTEND   |             Best Volume:   {soldbest}
  200.   OUTEND   |            Worst Volume:   {soldworst}
  201.   OUTEND   |
  202.   OUTEND   |EARNINGS:          Beans:  ${cashbeanwkly}
  203.   OUTEND   |                Zucchini:  ${cashzuccwkly}
  204.   OUTEND   |           Tomato Type 1:  ${cashtom1wkly}
  205.   OUTEND   |           Tomato Type 2:  ${cashtom2wkly}
  206.   OUTEND   |                    Corn:  ${cashcornwkly}
  207.   OUTEND   |                 Lettuce:  ${cashlettwkly}
  208.   OUTEND   |           --------------   ------------
  209.   OUTEND   |            Weekly Total:  ${cashwkly}
  210.   OUTEND   |           Daily Average:  ${cashavg}
  211.   OUTEND   |            Best Earning:  ${cashbest}
  212.   OUTEND   |           Worst Earning:  ${cashworst}
  213. END
  214.