home   |   links   |   (just HP-41 links)



HP-41 program to track time spent on various jobs


2/1/17   HP-41 program JOBTM (job time), for keeping hours for different jobs separate, for accounting purposes.  I wrote the original version in 1986, then revised it in Jan 2017.  Create the JOBHRS data file manually, with perhaps 8 registers, for account and time, plus 6 accounts.  Names will need to be edited in two places in the program as things you work on change.  I originally had it show in decimal hours, but changed my mind to keep it in hours and minutes.

Possible improvements would be to keep the account names in the file too, and make them show up in a menu so you don't have to remember them or change the program if the accounts change (only change the data file).

Program bytes:  approximately 267 bytes
Reg usage:  none in main RAM  (This is partly for safety.  A file would be less likely to get overwritten.)
JOBHRS data file reg usage:

   0: account you're adding time to right now, if applicable.  0 means not working on any right now.
   1: starting time for whatever job you're working on.  If no job right now, it will be the last stopping time.
   2: total completed time for 1st account.  This (and all following lines) are in HMS format.
   3: total completed time for 2nd account
   4: total completed time for 3rd account
      <etc.>


♦ LBL JOBTM                     \ First routine displays the collected hours.
♦ LBL 01
  "JOBHRS"  CLX  SEEKPTA        \ Name of file in XMEM is JOBHRS.  Start with begginning of file, for current time build.
  GETX  X=0?  GTO 07            \ If we're adding time to an account reg number right now (indicated by non-0),
     "ACCT "  FIX 00  ARCL X    \ show the register number of the account that's getting time added to it.
     "⊦ "
     GETX     FIX 02            \ Get the starting time, and FIX 2 for HH.MM display.
     TIME  X<>Y  HMS-           \ (It will never be exactly 0.)
     X>0?  GTO 10               \ If we passed midnight so it looks negative,
        24  HMS+                \ add 24.
♦    LBL 10     XEQ 09          \ Lines 22-23.
     GTO 08
♦ LBL 07                        \ Here's the "ELSE" condx.  If the account reg # we're adding time to now is 0 (meaning none),
     "DORMANT"  AVIEW           \ indicate that in the LCD.
     GETX   FIX 02              \ Make file pointer and FIX mode the same as they would have been otherwise.
♦ LBL 08
  "LFL E11 "  XEQ 02       \ Names and numbers of the different accounts (not reg #s).  Edit these as necessary.
  "ENG 191 "  XEQ 02       \ Ideally, name totals no more than 6 chrs plus space, so the display at LBL 02 doesn't scroll.
  "REP 610 "  XEQ 02       \ Examples now might be "LUNAR" and "MPCV".
  "ERE 266 "  XEQ 02       \ Lines 37-38.
  TONE 09    RTN           \ TONE indicates that there are no more accounts to display.
  GTO  01                  \ If R/S is pressed accidentally, we won't get any disorderly conduct. :D
-----------------
♦ LBL 02    GETX           \ Lines 42-43.
♦ LBL 09  ATIME24          \ For each account, add the time to the LCD in HH:MM.  The GETX inc's the file pointer, so we read the
  AVIEW   PSE   PSE        \ next account's total time each time subroutine 02 is called.  Give time to see "SOF 265 10:40"
  RTN                      \ for example.
-------------------------


♦ LBL "LFL"  XEQ 03        \ Labels were for account names.  You'll need to edit them, along with the above at LBL 08.
  2  SAVEX   RTN           \ "LFL" is for "lunar flashlight." The number refers to the register number in the file.
-----------------          \ File size should be adequate for the number of accounts you have.
♦ LBL "ENGG" XEQ 03        \ "ENGG" for "engineering" because "ENG" is for the display mode, like ENG 3.
  3  SAVEX   RTN
-----------------
♦ LBL "REP"  XEQ 03        \ Lines 60-61.
  4  SAVEX   RTN
-----------------
♦ LBL "ERE"  XEQ 03        \ Lines 65-66.
  5  SAVEX   RTN
-----------------
♦ LBL "QUIT"               \ QUIT can be used alone (manually, to end work), but is also
♦ LBL 03                   \ called from above to quit one job when starting another.
  "JOBHRS"  CLX  SEEKPTA   \ Lines 72-74.
  GETX                     \ Get the account # reg you're adding time to, from file reg 0.
  X=0?   GTO 04            \ Skip this part if we were not working on anything.  Else,
     TIME  GETX  HMS-      \ get the current time, minus the starting time              ^ acct_reg#  time
     X>0?  GTO 05          \ (It will never be exactly 0.)  Lines 81-82.
        24  HMS+           \ If it was negative from crossing midnight, add 24.
♦    LBL 05                \ ^ acct_reg#  time
     X<>Y  SEEKPT  X<>Y    \    "      "
     GETX  HMS+            \    "      "     Get the previous subtotal time, and add the new span of time to it.
     X<>Y  SEEKPT  X<>Y    \    "      "     Lines 91-93.
     SAVEX                 \    "      "     Store it back.
♦ LBL 04
  CLX  SEEKPT  SAVEX       \ In the acct# reg, store that we are not working on anything right now.
  TIME       SAVEX         \ Store the start/stop time.
  CLX  SEEKPT              \ Get ready for the calling routine to record the account reg number, if any.
  RTN                      \ Line 103.
---------------
  GTO 01                   \ (This is just to prevent accidentally going into CLRHRS, next, by pressing R/S.)

♦ CLRHRS
  "JOBHRS"  CLFL           \ Clear hours in file.  Does not do QUIT; so whatever you're working on now won't be undone.
  RTN                      \ Line 108.
-----------------



posted Jan 1, 2018       Garth Wilson   wilsonmines@dslextreme.com