home   |   links   |   (just HP-41 links)

HP-41 alarm and daytimer program (requested on two forums)

I've had this program in my HP-41cx for decades, without ever re-loading, and in its current form since 2001.  Every time I turn on the calc,

  1. it checks for pending alarms, and if there are any, it tells how long before the next one is due.
  2. If there are no pending alarms, it checks my DAYTMR (daytimer) file to see if it's supposed to remind of anything today, and if so, it puts it in the display.
  3. If there's nothing it's supposed to remind me of today, it puts the time and date in the display.
This all takes a couple of seconds before the 41 is ready for user input.  For me, it's definitely worth it.

One of the program sections, ALM, facilitates setting a relative alarm for the same day, for example to activate in 20 minutes, removing the need to remember what's supposed to go in X, Y, and Z for XYZALM.  This one is not made to handle passing midnight; so if you want an alarm for so many hours and minutes away on the next day, use ALMCLK which prompts for an absolute time of day, and a date.  I have these assigned to the CLΣ and BEEP keys, respectively.  (I also have the TIME and DATE functions assigned to keys.)

Getting the 41 to execute something automatically upon manual turn-on involves setting flag 11 and turning the calc off at the desired point in the program.  The code at label TOFF below does that.  When you turn the calc on manually, it will resume execution starting where it was when it was turned off (in this case by OFF in the program).  I keep TOFF assigned to the Σ+ key which I use as the OFF key, instead of pressing ON again.  The few times you may want to keep the program pointer where it was, and/or preserve the stack and/or ALPHA, you can still use the ON key to turn off the calc and the program below won't get used that time.

The section at label DAYTMR is to be used as a tickler file.  A text file with the same name will keep daily reminders.  The reason not to just use a message alarm is that you might not be close to the calculator to hear it when it sounds.  You could let it go and just see the message from a past-due alarm the next time you turn it on, but that's not very elegant.  You might also need to be reminded more than once during the day.  The way we do it here will remind you every time you turn it on on the specified day(s) unless you delete the corresponding line(s) in the DAYTMR text file, or modify the date portion of the line.

You may want to remove or modify certain parts that are there just for my own preference.  For example, I don't like the calc turning itself off when it thinks I'm done for a while, so I set flag 44, the continuous-on flag.  I use 44 TOGF which is in the ZENROM module, since ON is not programmable and SF__ doesn't allow setting flags above number 29 (even with the ZENROM module, which surprised me).  I also make it leave the calc in ENG 3 display mode which is my preferred setting.  There's minor synthetic programming, but nothing critical that can't also be done without it.  I don't think there's anything that requires any other module.  If I missed something, it might be in the Advantage or Extended I/O module.

As shown below, it's 210 bytes.  The \ is from Forth, another RPN language, where it makes the compiler or command-line interpreter ignore the rest of the line, for comments.

                   \ I assigned ALM to the CLΣ key.  Set a relative alarm, due in so many HMS regardless of what time it is.
 1 ♦ LBL ALM       \ Start with X containing the amount of time before you want the message alarm due.  Must be today.
 2   TIME          \ That gets added to the current time to end up with what the time will be when it's due.
 3   HMS+          \ It will be invalid if it goes past midnight into tomorrow.
 4   0             \ We only need two zeros here for date (today's
 5   0             \ date) and repetition interval (no repeats);
 6   0             \ but we do an extra 0 so that below, we can
 7   R^            \ use a roll-up to get the time in X.
 8   XYZALM        \ You can put in ALPHA whatever you want displayed when the alarm sounds.  (It could also be execution.)
 9   RTN
10 ♦ LBL ALMCLK    \ I assigned this to the BEEP key.
11   0
12   "ALM DATE=?"
14   "ALM TM=?"
16   "ALM CLK"     \ It just displays the message "ALM CLK" when it sounds.  Prompt for another string if you like.
18   "DONE"
19   AVIEW
20   PSE
21   TONE 89
23   RTN
24 ♦ LBL "TOFF"    \ I assigned this to the Σ+ key.
25   SF 11         \ This line is so it will auto-execute when turned on by hand.
26   TONE 57       \ Do three fast beeps of descending frequencies to give audible notice that it's turning off.
27   TONE 87       \ (synthetic programming)
28   TONE 70
29   OFF
30 ♦ LBL CKALM     \ Auto-executes here when you turn it on.  You might also want to assign this to a key.
31 ♦ LBL 04
32   44
33   TOGF          \ Set the continuous-on flag so the 41 won't turn itself off.
34   SF 25         \ Set the error-ignore flag so it will keep going in the event there is no alarm to recall.
35   E             \ E is just a faster synthetic-programming way to enter a 1.
36   RCLALM        \ Try to get the first alarm.
37   FC?25         \ If flag 25 got cleared, it's because there was no alarm to recall,
38   GTO 01        \ so go down to just display time and date.
39   CF 25         \ If flag 25 is still set, clear it now so errors will be trapped by the system.
40   TIME          \ Get the time to see how long until the alarm is due.
41   HMS-          \ Subtract it from the alarm time.
42   24            \ We'll add 24
43   HMS+          \ hours here (HMS+ needed for those times it goes from a negative to a positive nr)
44   24            \ and take MOD 24 in case the alarm is due past the next midnight.
45   MOD           \ Otherwise it could look like the alarm is due in a negative amount of time.
46   FIX 4         \ Get ready to display the time before the alarm is due as HH:MM:SS
47   "ALM: "       \ If the alarm is more than 24 hours away, the extra days are not shown.
48   ATIME         \ Put how long remaining until the alarm is due into the display.
49   GTO 03        \ Finish up below, as those instructions are common factors.

50 ♦ LBL 01        \ Come down here if there was no alarm pending.
51   "DAYTMR"      \ Put the name of the file in A,
52   CLX           \ the desired pointer value (the beginning of the file) in X
53   SEEKPTA       \ and set the current file and pointer in order to search for today's notices.
54   FIX 2         \ The file will show the date as MM/DD, so fix 2 before forming the search string.
55   DATE
56   CLA           \ Start with A clear because ADATE below will only add to the right end of A, not replace previous contents.
57   ADATE         \ Put xx/xx (month and date) in ALPHA to search for in the file.
58   POSFL         \ (POSition in FiLe)  Use the date string now in A to search the Daytimer file.
59   X<0?          \ A result of -1 means "string not found."
60   GTO 02        \ If that happened, skip the part that goes into the text editor to see the appropriate line.

61 ♦ LBL "DAYTMR"  \ (Assign this to a key.  I used Y^X.)
62   "DAYTMR"      \ Now put file name in ALPHA,
63   TONE 57
64   AON           \ turn on alpha keyboard,
65   TONE 57       \ give two 50ms beeps to indicate there's a notice today, and
66   ED            \ go into HP-41cx text editor with file name in A and pointer where the search left it.
67   AOFF          \ Upon exit, turn the alpha keyboard back off.  Then go on to show time and date below.

68 ♦ LBL 02        \ Jump to here if there were no Daytimer entries for today.
69   FIX 2         \ Get ready to display the time and date as HH:MM  MM:DD
70   TIME
71   " "           \ Start with a blank at the left end of the display so it won't be so crowded.
72   ATIME         \ Put the time in ALPHA,
73   "⊦ "          \ append a space to go between time and date,
74   DATE
75   ADATE         \ and put the date in ALPHA.
76 ♦ LBL 03
77   ENG 3         \ Set my favorite display mode for most of my work,
78   PROMPT        \ and stop with the ALPHA register in the display.  Stack is not left intact anymore.
79   GTO 04
80   END
If you get the NO ROOM message when trying to type something into the DAYTMR file, or if you need to claim back some space allocated to it, you can do that by using RESZFL, with DAYTMR being the current file, and X containing the number of registers you want to end up with for the file.  For example, if you go 20 RESZFL, you'll end up with 20 registers (140 bytes) for the file, regardless of what it was before.

It was originally intended that the first 5 characters in a DAYTMR line would be mm/dd (including a leading zero where necessary), but you can put two or more dates in a row if you want it to show the line more than one day.  For example:

02 01/24 01/25 BOBS HOUSE 8:30 TH

(02 being the line number).  Every time you turn on the calc on Jan 24th and 25th, you'll get the quick double beep, and it will go into the text editor, with this line in the display.  Pressing the ON button exits the editor.

last updated May 20, 2018       Garth Wilson   wilsonmines@dslextreme.com