In converting programs over to the 42S I have one program which relies on the built in "ATIME" function of the 41CX but has no analog in the 42S machine.
Quickly, the "ATIME" function of the HP41CX converts a numeric value into a time display format in the ALPHA mode. The numeric value must already have been converted to HMS.
example 1, fix 2 display:4.20
ATIME
AVIEWyields 04:20.
Seems simple enought but what went on behind the scene. Firstly a zero is added infront of the 4 in the hours format. A colon is added separating the hours from the minutes. The next digit is added and a final zero is appended after the 2.
using fix 4 will add a seconds display with colon and subsequent zeros;
yielding 04:20:00
The following program will output to a printer:
LBL ATIMES
CLA
ARCL 00
ATIME
"__"
ARCL 01
ATIME
AVIEW
END
Using 4.2 in REG 00 and 10.15 in REG 01 yields:
04:20__10:15
The HP 42S without the ATIME or a subroutine and the following code:
LBL ATIMES
ARCL 00
"__"
ARCL 01
AVIEW
END
As above, using 4.2 in REG 00 and 10.15 in REG 01 yeilds:
4.2__10.15
After creating a program for the HP 41CX, which gives three differing types of break schedules and printing them out in the following form is:
START= 22:35
END= 06:25TOTAL= 07:50
LONG= 02:00
SHORT= 00:36# BREAKS= 6
22:35__23:11
23:11__23:48
23:48__01:48
01:48__03:48
O3:48__05:48
O5:48__06:25
you can see the output is similar for each type of number and the columns line up.
The same program for the HP42S without the "ATIME" function is:
Start= 22.35
End= 6.25Total= 7.50
Long= 2.00
Short= 0.36# Breaks= 6
22.35__23.11
23.11__23.48
23.48__1.48
1.48__3.48
3.48__5.48
5.48__6.25
A bit messy in my opinion.
Now that the problem has been stated. I had some ideas sent to me and then combined that with a subroutine designed to accomodate hours and minutes (modify for seconds display if you want). I came up with this "ATIME" substitute which I call in the LBL "ATIME" subroutine.
{ 73-Byte Program}
LBL "ATIME"
FIX 02 -fix 2 display
STO 15 -store variable sent to this program
ENTER -duplicate the entry for the y stack
10 -test for less than or equal to 10.00 hours;
X<=Y? do we need to run this routine for a
SF 08 preceding zero? 04.20?
RDN
FS?C 08
GTO 10
APPEND "0"
LBL 10 -did not need preceding zero, do we need the
AIP colon? of course for all cases.
APPEND ":"
FP -get the minutes portion and multiply by 100
1E2
X
X=0? -if minutes equals zero GTO 20 which adds two
GTO 20 zeros to the end of the display
ENTER
10
X<=Y? -if the minutes has only one digit in the
SF 08 ones position; i.e. '4' then stick a
FS?C 08 zero in front of the 4 giving '04'
GTO 15 -if not then proceed
APPEND "0"
LBL 15 -if no 0 is required on the minutes portion.
AIP
RCL 15 -in my main routine this call of the original
RTN number is required for subsequent time
LBL 20 calculations.
APPEND "00" -if two zeros required in the minutes portion.
RDN
RCL 15
RTN
This program in conjunction with my Break program on the HP42S prints identically to the HP41CX:
START= 22:35
END= 06:25TOTAL= 07:50
LONG= 02:00
SHORT= 00:36# BREAKS= 6
22:35__23:11
23:11__23:48
23:48__01:48
01:48__03:48
O3:48__05:48
O5:48__06:25
Now I know this is probably not the most elegant way of tackling this but it sure does show the value of Functions versus Subroutines for saving space.
I can now take the HP42S into the cockpit and see how it performs!
Cheers,Geoff
PS thanks Diego for the preliminary suggestions.
Edited: 21 Oct 2008, 7:30 p.m. after one or more responses were posted