RE: HP 33s programming Message #10 Posted by Alexander Thorp on 28 Feb 2005, 11:58 p.m., in response to message #9 by Norris
You hit the nail on the head in terms of describing what I am after, and maybe I'm out of luck.
However, I'll share what I've been working on. It involves user INPUT in the main routine of "subject number" S, "equation number" E, and "variable number" V, and utilizes the indirect address (i) to call the appropriate subroutine:
A0001 LBL A
A0002 INPUT S (pick one of 17 subjects)
A0003 INPUT E (choose equation no. - predefined)
A0004 RCL S
A0005 1
A0006 +
A0007 STO i
A0008 FN=(i) (defines label within which the SOLVE will occur)
A0009 INPUT V (here, V is a number which corresponds to the letter of the variable to be solved for...A=1, B=2, and so on)
A0010 STO i
A0011 SOLVE(i)
A0012 VIEW(i)
The main routine above works great in terms of calling the subroutine and beginning the SOLVE process. If the subject no. 1 subroutine had only one equation (the area of a circle), it might look like this:
B0001 LBL B
B0002 SF 11
B0003 A=(PI)x(R)x(R)
B0004 RTN
in which case it would work great with the main routine.
But what I'm trying to do is use variable E defined in the main routine (equation number) to call out one of a series of equations all within the same "label".
I was hoping the format of this might be as simple as:
B0001 LBL B
B0002 SF 11
B0003 1
B0004 RCL E
B0005 x=y?
B0006 A=(PI)x(R)x(R)
B0007 2
B0008 RCL E
B0009 x=y?
B0010 V=4/3x(PI)xRxRxR (volume of a sphere)
B0011 3
B0012 RCL E
B0013 x=y?
and so on.
EXCEPT that it doesn't seem to work. Apparently, there needs to be an RTN statement after each equation, once solved, to go back to the main routine. But, unfortunately, I can't simply place an RTN statement after each equation, as the program would then never get past equation number 1...I've tried making the RTN statement conditional upon comparing variable E with the equation number following the SOLVE, but it gets botched up...I don't know why, but I can't figure out how to do it.
I'm not sure exactly the syntax involved in the SOLVE routine, but I'm guessing that the result is that it stores the answer in the variable that is solved for. Maybe it also enters this value in the x-register?
Anyway, I think I'm done trying to make this work - I'd better get back to studying instead of getting distracted by this unfruitful programming....unless of course someone could think of a way, and would be willing to share it...
Thanks for all the help, everyone!
|