HP Articles Forum
[Return to the Index ]
[ Previous | Next ]
Frequency
Posted by Eric Smith on 11 Apr 2005, 4:32 a.m.
As I was searching for something else entirely amongst old issues of 65 Notes and PPC Journal, I came across this gem. In addition to serving as an example of a useful programming technique for storing many binary values (flags) in a single numeric register, I thought it might also prove to be of practical value to some MoHPC readers.
As my wife and I sat in our living room one fall evening, the kids all in bed, the conversation somehow evolved around to a discussion of the frequency of the marital relationship in our household. As the conversation progressed, it became quite apparent to me, that my wife was under the false impression that it was much more frequent than I knew it to be. I finally suggested, as a solution to this disagreement, that we "buy a calendar for our bedroom wall and circle all days on which activity occured." My wife, being a little perturbed by now, stated very sarcastically, "Isn't there a way you can put that in your calculator?" That statement only shows some of her animosity toward her main competitor for my time and affection, namely my HP-67 pocket calculator.
After thinking about what she'd said for a day or so, it occured to me that it really wasn't a bad idea. After all what a great opportunity to demonstrate to her how useful the HP-67 was in solving common household problems.
Researching my back issues of "65 Notes", I found Jake Jacobs (99) article on "Storing 33 Flags in One Register" - (V3N9P11). Oh! Just what I needed! With a little work, the following program resulted. I call it "Frequency".
Enter a date (mm.dd) on which activity occured and push "A" to enter it into the calculator memory. If you make a mistake entering, enter the same data (mm.dd) and hit "B" to erase it. To see the activity for any given date, enter the date (mm.dd), push "C" and receive a "yes" or "no" answer. To get the complete listing of the activity for a given month, just enter the month number and hit "D". Enter a date (mm.dd) and hit "E" to ge the last prior date on which activity occured. (It can take approximately three minutes to search twelve months if no activity is recorded). The program is carefully written to take up only one side of one card, so program can be on one side and the record of one years "activity" can be stored on the other side of the same card.
My wife was, needless to say, thrilled to see such a unique solution to such a difficult problem. Although she's never actually said it, I do get the feeling that on one of her more trying days, she'd like to not only say "no" but add "and you can stick that in your calculator."
I sent a copy of this story to Lou Cargile, Jr. (753) as I thought he might get a kick out of it. He answered with, and I quote, "Could the program be expanded to make it possible to rate each entry on a scale of 1 to 10 so as to keep a log of quality as well as quantity? I guess this would quickly require two 67's at each bedside---disagreements will arise--- but think of the potential market."
An excellent suggestion I thought, but since I haven't had the time to explore that possiblity, I leave that challenge up to the membership.
A footnote to this story: I hate to admit that I didn't discover this glitch in the program through actual use, but as I was checking out the program for publication, I found that when you try to record activity for all thirty one days of the month, the entry of the thirty-first day bombs the record of activity stored for the first, eleventh, and twenty-first. Realizing the devastating effect this constraint places on the "marital relationship", once again I contact that HP Wizzard of Wizzards, Lou Cargill, Jr. and here is his authoritative evaluation of the situation, and again I quote---"I think the calculator's handling of 31 days of consecutive "activity" in one month is probably jealousy, pure and simple. Do you suppose the calculator, like a mistress, is willing to share you, but just run up 31 days without one day of undivided attention and this occurs?"
Enough said---elsewhere in this issue you will find my program titled, "FREQUENCY".
Author's name withheld at wife's request(?) (1507)
Step Key Entry Key Code ---- ------------ -------- 1 LBL A 31 25 11 GSB C 31 22 13 x/=0? 31 61 RTN 35 22 5 2 02 RCL 0 34 00 1 01 - 51 y^x 35 63 10 STO + i 33 61 24 RTN 35 22 LBL B 31 25 12 GSB C 31 22 13 x=0? 31 51 15 RTN 35 22 2 02 RCL 0 34 00 1 01 - 51 20 y^x 35 63 STO - i 33 51 24 RTN 35 22 LBL C 31 25 13 GSB 4 31 22 04 25 LBL 3 31 25 03 STO 0 33 00 RCL i 34 24 2 02 RCL 0 34 00 30 3 03 2 02 x<=y? 32 71 COS 32 63 Rdn 35 53 35 y^x 35 63 / 81 FRAC 32 83 . 83 5 05 40 x>y? 32 81 CLx 44 RTN 35 22 LBL D 31 25 14 GSB 4 31 22 04 45 1 01 LBL 9 31 25 09 GSB 3 31 22 03 RCL 0 34 00 49 + 61 50 PAUSE 35 72 1 01 STO + 0 33 61 00 RCL 0 34 00 GTO 9 22 09 55 LBL 4 31 25 04 1 01 0 00 x<>y 35 52 x>y? 32 81 60 + 61 DSP 1 23 01 STO I 35 33 FRAC 32 83 EEX 43 65 2 02 * 71 RTN 35 22 LBL E 31 25 15 GSB 4 31 22 04 70 1 01 - 51 GTO 6 22 06 LBL 5 31 25 05 x<>I 35 24 75 LBL 6 31 25 06 GSB 3 31 22 03 x/=0? 31 61 GTO 2 22 02 RCL 0 34 00 80 x<>I 35 24 DSZ 31 33 GTO 5 22 05 x<>I 35 24 LBL 7 31 25 07 85 DSZ 31 33 GTO 8 22 08 2 02 2 02 STO I 35 33 90 LBL 8 31 25 08 RCL i 34 24 x=0? 31 51 GTO 7 22 07 3 03 95 1 01 GTO 6 22 06 LBL 2 31 25 02 1 01 0 00 100 RCL I 35 34 101 INT 31 83 x>y? 32 81 - 51 ABS 35 64 105 RCL 0 34 00 EEX 43 2 02 / 81 + 61 110 DSP 2 23 02 111 RTN 35 22
Input Output Step Instructions Data/Units Keys Data/Units ---- --------------------------------------- ---------- ---- ------ 1 Load side one 1a Load side two if you have previously recorded some data on it. 2 Enter date (mm.dd) on which activity occured.
Registers:
0 Day # 1 Jan. 2 Feb. 3 Mar. 4 Apr. 5 May. 6 Jun. 7 Jul. 8 Aug. 9 Sept. A Oct. B Nov. C Dec. D E I month
Labels:
A store B erase C test D list E prior 0 1 2 display date 3 check 4 initialize 5 decrementing months and days ---- 9 month
Edited: 11 Aug 2011, 1:03 p.m.