The Museum of HP Calculators

HP Forum Archive 17

[ Return to Index | Top of Index ]

UserRPL Programming problem
Message #1 Posted by Franco on 26 Mar 2007, 3:47 p.m.

Hi all, I'm trying to resolve a problem with my 50g: I have three variables "y", "m" and "d" that contain respectively year, month and day of a certain date. I vant to do some action only if that date is after a given date (for example, August 14, 1996). The quickest mode that I've found is to divide month and day respectively by 100 and 10000, sum these number and make the test. Example: y m 100 / + d 10000 / + -> test IF test 1996.0814 > THEN...

It works, but I'm not satisfied. It's inelegant. There is a more elegant way to do this task with my 50g?

Greetings,

Franco

      
Re: UserRPL Programming problem
Message #2 Posted by GT Springer on 26 Mar 2007, 7:06 p.m.,
in response to message #1 by Franco

There is a DDAYS (Delta Days) command that will tell you indirectly if one day is before or after another. Dates in the 50g are of the form mm.ddyyyy or dd.mmyyyy (depending on flag -42 setting). For two such dates in levels 1 and 2 of the stack, DDAYS returns the number of days between them. The number of days is positive if the level 1 data is later than the level 2 and negtive if earlier. I do not know whether or not this gives you a more elegant solution - if y, d, and m are useful variables for you elsewhere, it may not be worth the conversions. I hope this was helpful to you.


[ Return to Index | Top of Index ]

Go back to the main exhibit hall