Post Reply 
Summing lists in directory structure
09-15-2017, 08:51 PM (This post was last modified: 09-15-2017 09:12 PM by Gilles59.)
Post: #5
RE: Summing lists in directory structure
(09-14-2017 11:17 AM)brickviking Wrote:  Now I'm wondering how to add together all the TOTALs in each folder to give me a sum at the end?
Cheers, brickviking
(Post 82)

Hi Brick

put this program in your grocery directory

Code:
TYear
«
 0.
 {'JAN' 'FEB' 'MAR' .... 'OCTOB' 'NOV' 'DECEM' }
 1. « EVAL TOTAL + UPDIR » DOSUBS
»

And you get the total.
But this suppose that all your directory structure (JAN FEB etc) is created and that the TOTAL object exits in each directory.

If the TOTAL sometimes does not exist :

Code:
«
 0.
 {'JAN' 'FEB' 'MAR'  .... }
 1. « EVAL IF TOTAL DUP TYPE 6. == THEN DROP ELSE + END UPDIR » DOSUBS
»

Quote:I'm sure that if I could run a program in the GROCERIES folder iterating over each month

To create, calculate or update automatically the TOTAL for a month, here is an idea :

Code:
'TMonth'
«
   -> Month
  «
   Month EVAL
   0. 'TOTAL' STO
   VARS S~N 1.
   « IF DUP Month S~N POS 
      THEN S~N EVAL AXL CNRM 'TOTAL' STO+ 
      ELSE DROP END »
   DOLIST
  UPDIR
 »
»

STOre this in your grocery directory.
Usage :
'JAN' TMonth

Warning : flag -86 must be set or type once 256 ATTACH


To update all automaticaly and calculate months and year total, you can put this program in your grocery directory :

Code:
<< {'Jan' 'Feb' .... 'Dec'} << TMonth >> DOSUBS TYear >>
(not tested all of this but I think it will work)

What is your MONTOT  object for ?

EDIT : I dont know how you create your RPL program, but I suggest you to use HPUserEdit with Emu48
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Summing lists in directory structure - Gilles59 - 09-15-2017 08:51 PM



User(s) browsing this thread: 1 Guest(s)