24hr Time Calculations - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html) +--- Forum: General Forum (/forum-4.html) +--- Thread: 24hr Time Calculations (/thread-18381.html) |
24hr Time Calculations - syzygetic - 05-17-2022 06:18 PM Anybody have a good program for calculating the elapsed time between two times? As an example, in HHMMSS format, 090000 to 163200 is 7h32m My particular use case is on a DM42, so any HP42 program should work fine, but I can't seem to find one out there. My intent is to take the program and integrate the sum feature, so I can add the resultant elapsed times to those registers and use the stats features on them. RE: 24hr Time Calculations - Garth Wilson - 05-17-2022 07:25 PM Does it have the HMS- function like the 41cx (and probably the Time module too)? RE: 24hr Time Calculations - Peet - 05-17-2022 07:38 PM Page 84 in the HP42s OM RE: 24hr Time Calculations - Steve Simpkin - 05-17-2022 07:44 PM As Garth and Peet mentioned, no programming necessary. The HP-42S/DM42/Free42 does have the HMS+ and HMS- functions. They use the HH.MMSSss format for time entry. Use FIX 4 (for HH.MM.SS) of FIX 6 (for HH.MM.SSss) display format for best results. For your example type : 16.3200 [ENTER] 9.0000 [HMS-] The answer is 7.3200 (with the display set to FIX 4). You might want to assign the HMS+ and HMS- functions to the Custom menu if you use them frequently. RE: 24hr Time Calculations - Dave Britten - 05-17-2022 07:55 PM As others have mentioned, the HMS- function is already there, but keep in mind it will return results that are also in HH.MMSS format (meaning you can't sum those directly). You'll need to use the →HR function to convert from HH.MMSS to decimal hours, then you can sum up those results. RE: 24hr Time Calculations - syzygetic - 05-17-2022 10:01 PM Thanks all, this is exactly what I needed! I'll whip up a quick program around this function and be set! RE: 24hr Time Calculations - syzygetic - 05-17-2022 11:56 PM Ok, so now I started with the following, which I'll loop later: Code:
But I get a "Nonexistent" from Free42. This is literally my second program in a 42s ever... any debug ideas? RE: 24hr Time Calculations - Thomas Klemm - 05-18-2022 01:27 AM Your program works fine when I copied and pasted it into Free42. However it shortened the 2nd variable "DAY START" to "DAY STA": Code: 00 { 48-Byte Prgm } You get a "Nonexistent" message if the variable isn't created yet but the program wants to access it. This might happen for instance if the program starts at line 04. In such a case you can single step through the program with the SST or just the ▼ key. While you press down the key the current line is displayed: Code: 03 INPUT "DAY STA" HTH RE: 24hr Time Calculations - Steve Simpkin - 05-18-2022 01:29 AM (05-17-2022 11:56 PM)syzygetic Wrote: Ok, so now I started with the following, which I'll loop later: Your program seems to work as-is for me in Free42. I copied and pasted it into both mobile and desktop versions of Free42 and it works fine. RE: 24hr Time Calculations - syzygetic - 05-18-2022 03:10 AM Interesting, thanks guys! This is my first time using winFree42 so maybe I have some setting messed up. I'll load it up on the real thing tomorrow and develop a bit more. RE: 24hr Time Calculations - Peet - 05-18-2022 07:55 AM (05-18-2022 01:27 AM)Thomas Klemm Wrote: However it shortened the 2nd variable "DAY START" to "DAY STA": on the 42s a variable name can have one to seven characters RE: 24hr Time Calculations - syzygetic - 05-18-2022 11:34 AM Indeed, it was the variable length, thanks. I shortened it up and Free42 and the DM42 both like this now. On to looping! Code:
Thanks all, great forum here! RE: 24hr Time Calculations - Thomas Klemm - 05-18-2022 08:35 PM Glad, we could help. (05-17-2022 11:56 PM)syzygetic Wrote: This is literally my second program in a 42s ever... This is amazing. I started programming on an HP-41CV as a teenager in the 80's. All I had was curiosity, excellent manuals, and plenty of time. I can hardly imagine what that would be like for me today. However, I wish you a lot of fun on your journey. It piqued my interest as to what might have caused the problem. So, I encoded your program with the DM42 Programming tool. And lo and behold, it doesn't shorten the name of the variable. I downloaded the .raw file into Free42 and ran your program and got the same error message: Nonexistent It seems that the INPUT "DAY START" command creates a variable with a corrupted name. These are the two variables, if they are used in a program: Code: 00 { 20-Byte Prgm } No wonder that this can't be found. RE: 24hr Time Calculations - syzygetic - 05-19-2022 02:21 PM (05-18-2022 08:35 PM)Thomas Klemm Wrote: This is amazing. I started programming on an HP-41CV as a teenager in the 80's. I have to say, the manuals are indeed excellent. I have a lot of experience with other languages, just nothing in RPN/RPL, and really nothing stack based, such as FORTH. It's refreshingly simple, though, even if it's a lot more encumbered here because of the need to compile, them import to an emulator or calculator. I do wish there were a command line utility I could use for development work, just to reduce the turnaround time on debugging like this. RE: 24hr Time Calculations - Thomas Klemm - 05-19-2022 03:11 PM (05-19-2022 02:21 PM)syzygetic Wrote: I do wish there were a command line utility I could use for development work, just to reduce the turnaround time on debugging like this. There's an extension for VS Code you might consider: (12-19-2018 04:48 PM)Heilingbrunner Wrote: More details see Visual Studio Code Marketplace - HP42S-free42. This linked thread might be of interest as well: Txt to Raw and Raw to Txt RE: 24hr Time Calculations - Thomas Klemm - 05-22-2022 12:34 PM There's yet another way: (Free42) txt2raw - raw2txt |