Post Reply 
Summing lists in directory structure
09-18-2017, 10:26 AM (This post was last modified: 09-19-2017 02:08 AM by brickviking.)
Post: #14
RE: Summing lists in directory structure
(09-15-2017 08:51 PM)Gilles59 Wrote:  To create, calculate or update automatically the TOTAL for a month, here is an idea :

I'll try comment how I think separate commands work, but I have some questions about how it all works. I'm sorry I have to @ comment@ @every@ @keyword@, but I'm new to this... oh wait, I've said that already, several times.

If I hadn't used varnames that began with the month I was storing them in, what would have been used instead? i.e. Jan/value1, .../value2, .../value3 etc?

'TMonth'  @ name - gee, I'm bright! @
   -> Month  @ Create local var, though I had to get rid of the "->" and put in the single char for it: "" (assuming that's a right-pointing arrow like →) @
   Month EVAL  @ change directory to what's in Month. What happens if the month doesn't exist as a dir? @
   0. 'TOTAL' STO   @ Stick zero into TOTAL, as we're going to add it all up @
   VARS                @ create list of variables in subdir @
S~N  @ turn them all into a list of strings @
1.  @ grab 1 entry from the list (part of how DOLIST works) @
   « IF 
         DUP @ create a duplicate of entry grabbed from list @
         Month S~N @ Turn Month varname into a string @
         POS  @ find its position in the previous string @
      THEN @ dump the test result, it was successful @
         S~N  @ Turn the var string back into a varname @
         EVAL @ Put it on the stack @
         AXL CNRM @ Turn it into an array and add it up @
'TOTAL' STO+  @ add this to TOTAL, removing it and 'TOTAL' from the stack @
      ELSE @ dump the 0 (test result) @
        DROP @ otherwise, ignore this string (remove it from the stack) @
      END » @ rinse, repeat. Pull another list entry until there aren't any more @
   DOLIST @ process each member of the list @
  UPDIR  @ change back up a directory @

Quote:Warning : flag -86 must be set or type once [i]256 ATTACH
Where can I find a shorter shortcut to the devel menu aside from Apps->Up->Up->F6 ?

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

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

Yep, it certainly looks like it will.

(Post 87)

Regards, BrickViking
HP-50g |Casio fx-9750G+ |Casio fx-9750GII (SH4a)
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 

Messages In This Thread
RE: Summing lists in directory structure - brickviking - 09-18-2017 10:26 AM

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