Post Reply 
HP50g small tips and trick
08-08-2018, 08:44 AM
Post: #49
RE: HP50g small tips and trick
I don't know if this has made it to anywhere I've seen yet, so I thought I'd share it for the newer users among us. Here's an explanation of the code snippet I came up with:

Code:

@Help: makes the current foldername usable for the program without the remainder of the PATH
\<<
  PATH @grab the full path to the place the code is called FROM (not the folder the program resides in)
  DUP @needed so we have a copy for GET 
  SIZE @ how large is the list? Leave it on the stack
  GET  @get the SIZEth element of the first PATH, i.e. the last entry in PATH
  \-> FName  @ stick it in a local var for use by the program
  \<< FName .... @ fill your code in here
  \>>
\>>

Now, onto how I used it. A while ago, Gilles59 provided me with some useful programs that I used:

(09-15-2017 08:51 PM)Gilles59 Wrote:  To create, calculate or update automatically the TOTAL for a month, here is an idea :

I added the above snippet to my program so it grabs its own folder name, now I simply call the program from the folder with the totals in, so there's no more changing folders within the program.
Here's how I used it. The TL;DR goes like this; I created a series of folders (JAN..DECEM), with totals for each grocery run inside, some examples are:

Code:

@ Path: { HOME GROCERY GRC2018 AUG }
{ 215.22 43.99 15.00 } AUG07 STO

@ Path: { HOME GROCERY GRC2018 MAY }
{ 237.96 55.27 12.00 2.00 17.00 6.30 } MAY01 STO
{ 274.74 38.00 14.00 8.00} MAY15 STO
{ 283.13 79.60 29.30 8.00 30.90 } MAY29 STO

The requirement I had was that each varname had to have the month name embedded in it somewhere, or it'd simply get ignored by later code. Most of the code below was pulled from the previous post I made.

Code:
@name: 'GRCMonthTotal'
«
  PATH @grab the full path to the current folder
  DUP @needed so we have a copy for GET 
  SIZE @ how large is the PATH list? Push that onto the stack
  GET  @grab the last entry in PATH
  -> Month  @ Create local var with the name of the month
  @ in my example, needs to be one of these: [JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEPT|OCTOB|NOV|DECEM]
  «
   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 with the preceding IF-THEN-END @
   TOTAL @grab total, as we're about to display it
   Month -\>TAG @make it displayable, and push the result to the stack
 »
»

Quote:Warning : flag -86 must be set or type once [i]256 ATTACH

(Post 266)

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
HP50g small tips and trick - Vtile - 12-13-2016, 11:58 PM
RE: HP50g small tips and trick - tdh79 - 12-19-2016, 11:27 AM
RE: HP50g small tips and trick - franz.b - 06-13-2018, 10:55 AM
RE: HP50g small tips and trick - ttw - 12-19-2016, 07:38 PM
RE: HP50g small tips and trick - Carsen - 01-02-2017, 05:21 AM
RE: HP50g small tips and trick - Vtile - 01-03-2017, 08:55 AM
RE: HP50g small tips and trick - grsbanks - 01-11-2017, 01:29 PM
RE: HP50g small tips and trick - Joe Horn - 01-11-2017, 06:32 PM
RE: HP50g small tips and trick - Vtile - 01-11-2017, 06:05 PM
RE: HP50g small tips and trick - grsbanks - 01-11-2017, 06:56 PM
RE: HP50g small tips and trick - DavidM - 01-11-2017, 09:07 PM
RE: HP50g small tips and trick - Vtile - 01-11-2017, 11:41 PM
RE: HP50g small tips and trick - grsbanks - 01-12-2017, 09:19 AM
RE: HP50g small tips and trick - Vtile - 01-17-2017, 01:30 PM
RE: HP50g small tips and trick - ttw - 02-06-2017, 07:47 PM
RE: HP50g small tips and trick - ttw - 02-20-2017, 09:21 PM
RE: HP50g small tips and trick - C.Ret - 06-14-2018, 07:17 AM
RE: HP50g small tips and trick - TomC - 06-23-2018, 04:50 PM
RE: HP50g small tips and trick - Juan14 - 07-04-2018, 02:55 PM
RE: HP50g small tips and trick - Joe Horn - 07-04-2018, 04:52 PM
RE: HP50g small tips and trick - DavidM - 07-04-2018, 05:39 PM
RE: HP50g small tips and trick - Carsen - 06-13-2018, 08:12 AM
RE: HP50g small tips and trick - Vtile - 06-13-2018, 08:33 PM
RE: HP50g small tips and trick - Carsen - 06-13-2018, 09:34 PM
RE: HP50g small tips and trick - Joe Horn - 06-14-2018, 05:30 AM
RE: HP50g small tips and trick - Vtile - 06-14-2018, 09:30 PM
RE: HP50g small tips and trick - Carsen - 06-14-2018, 06:28 AM
RE: HP50g small tips and trick - rprosperi - 06-14-2018, 12:08 PM
RE: HP50g small tips and trick - Joe Horn - 06-14-2018, 01:09 PM
RE: HP50g small tips and trick - DavidM - 06-14-2018, 02:27 PM
RE: HP50g small tips and trick - Joe Horn - 06-15-2018, 02:15 PM
RE: HP50g small tips and trick - Carsen - 06-15-2018, 08:36 AM
RE: HP50g small tips and trick - Joe Horn - 06-15-2018, 03:20 PM
RE: HP50g small tips and trick - Carsen - 06-16-2018, 08:40 AM
RE: HP50g small tips and trick - Joe Horn - 06-16-2018, 06:15 PM
RE: HP50g small tips and trick - pier4r - 06-16-2018, 07:15 PM
RE: HP50g small tips and trick - DavidM - 06-16-2018, 09:26 PM
RE: HP50g small tips and trick - grsbanks - 06-17-2018, 07:59 AM
RE: HP50g small tips and trick - DavidM - 06-17-2018, 02:29 PM
RE: HP50g small tips and trick - Vtile - 06-17-2018, 07:01 PM
RE: HP50g small tips and trick - pier4r - 06-23-2018, 03:15 PM
RE: HP50g small tips and trick - rprosperi - 06-23-2018, 04:26 PM
RE: HP50g small tips and trick - pier4r - 06-23-2018, 05:43 PM
RE: HP50g small tips and trick - TomC - 06-23-2018, 05:02 PM
RE: HP50g small tips and trick - DavidM - 06-23-2018, 05:35 PM
RE: HP50g small tips and trick - brickviking - 08-08-2018 08:44 AM
RE: HP50g small tips and trick - pier4r - 08-08-2018, 09:25 AM
RE: HP50g small tips and trick - pier4r - 08-08-2018, 11:18 AM



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