 Need to convert FIF49 to Prime version - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html) +--- Forum: HP Prime (/forum-5.html) +--- Thread: Need to convert FIF49 to Prime version (/thread-10922.html) Pages: 1 2 Need to convert FIF49 to Prime version - Mikebike - 06-16-2018 02:23 PM Hi, I am an old 48GX user who's 48 is dying so I have purchased a new HP Prime. I have never done any programming but frequently use a program called FIF49 located on HPCALC.org It is a program that adds measurements in feet inches and fractions together in a RPN calculator. I don't believe it runs on the Prime but I was wondering if anyone here could help me get it converted. I am hoping that you might be able to look at the program and see if you could possibly convert it to run on the Prime. It would be a great help. I will eventually learn the Prime programming but this is something I need for work so I don't have the luxury of time. I am hoping it is a simple conversion. FIF49 RE: Need to convert FIF49 to Prime version - Eddie W. Shore - 06-18-2018 12:51 PM For the HP 48/49 experts: what is # 181057d SYSEVAL? Thanks. I can see if I can get something similar, I have flirted with programming with feet-inches programming, except that the numbers are in ff.ii (feet - inches) format and I use functions specific functions to add and multiply such numbers. Eddie RE: Need to convert FIF49 to Prime version - Mikebike - 06-18-2018 02:16 PM (06-18-2018 12:51 PM)Eddie W. Shore Wrote:  For the HP 48/49 experts: what is # 181057d SYSEVAL? Thanks. I can see if I can get something similar, I have flirted with programming with feet-inches programming, except that the numbers are in ff.ii (feet - inches) format and I use functions specific functions to add and multiply such numbers. Eddie Thank you Eddie RE: Need to convert FIF49 to Prime version - grsbanks - 06-18-2018 03:27 PM (06-18-2018 12:51 PM)Eddie W. Shore Wrote:  For the HP 48/49 experts: what is # 181057d SYSEVAL? #181057d = #2C341h => ?DispStack (HP-49/50, not 48) It will re-display the stack now if needed. RE: Need to convert FIF49 to Prime version - Joe Horn - 06-18-2018 03:29 PM (06-18-2018 12:51 PM)Eddie W. Shore Wrote:  For the HP 48/49 experts: what is # 181057d SYSEVAL? Thanks. That's the entry point for the ?DispStack command in the 50g. HP 48S/SX/G/GX: #39B85h SYSEVAL --> ?DispStack HP 50g: #2C341h SYSEVAL --> ?DispStack Donnelly's Gray Book describes it thus: "If no keys are in the keybuffer, draws the stack area, otherwise does not draw the stack area and executes SetDA2aBad." EDIT: Oops, grsbanks beat me to it. RE: Need to convert FIF49 to Prime version - DavidM - 06-18-2018 03:42 PM (06-18-2018 12:51 PM)Eddie W. Shore Wrote:  what is # 181057d SYSEVAL? Thanks. Here's the descriptions for the SYSEVAL references I saw in the source: #181057d SYSEVAL: ?DispStack Redisplays the stack immediately during a running program if necessary #155601d SYSEVAL: DISPROW7 Displays a string on row 7 of the display #192145d SYSEVAL: SetDA2Valid Sets the disposition of display area DA2 as valid (similar to FREEZE for that part of the display) #192103d SYSEVAL: SetDA1Valid Sets the disposition of display area DA1 as valid (similar to FREEZE for that part of the display) #180985d SYSEVAL: DispStsBound Displays a horizontal line at y=14, normally the separation between header and stack RE: Need to convert FIF49 to Prime version - Eddie W. Shore - 06-21-2018 12:35 PM I have a program in process that does work with feet-inches, I adopted it to use the structure of the Prime. Here is what I have: The program FTIN has the user select the accuracy (1/2 to 1/64). You enter units through a menu (feet, inches, fractions or square feet). The operations available: Add and subtract feet-inches Multiply and divide by a scalar Multiply feet-inches to a square feet area (rounded to the nearest 6 decimal places) Divide an area by a length Find a diagonal of a square area Code: ``` sub1(); sub2(); EXPORT FTIN() BEGIN // 2018-06-21 EWS // initialization LOCAL fx,fy,fz,ch; LOCAL lx,ly,lz,Y,S; LOCAL aflag,str,dh; INPUT({{Y, {2,4,8,16,32,64}}}, "ACCURACY DESIRED","/"); Y:=2^Y; // initial entry CHOOSE(dh,"Initial Units", {"ft-in","ft^2"}); IF dh==1 THEN fx:=sub1(); fz:=fx; aflag:=0; ELSE INPUT(fx,"Enter Area","ft^2:"); fz:=fx; aflag:=1; END; WHILE ch≠9 DO fx:=fz; // string for fz IF aflag==0 THEN lx:=sub2(fx,Y); str:=STRING(lx(1))+" ft "+ STRING(lx(2))+" "+ STRING(lx(3))+" in"; ELSE str:=STRING(fx)+" ft^2"; END; CHOOSE(ch,str, {"Add ft-in", "Subtract ft-in", "Multiply by scalar", "Divide by scalar", "Multiply to area", "Divide from area", "Diagonal from area", "Change accuracy seetings", "Quit"}); // add ft-in IF ch==1 THEN fy:=sub1(); fz:=fx+fy; lx:=sub2(fx,Y); ly:=sub2(fy,Y); lz:=sub2(fz,Y); PRINT(); PRINT(lx(1)+" ft "+lx(2)+ " "+lx(3)+" in"); PRINT("+"); PRINT(ly(1)+" ft "+ly(2)+ " "+ly(3)+" in"); PRINT("="); PRINT(lz(1)+" ft "+lz(2)+ " "+lz(3)+" in"); WAIT(0); END; // subtract ft-in IF ch==2 THEN fy:=sub1(); fz:=fx-fy; lx:=sub2(fx,Y); ly:=sub2(fy,Y); lz:=sub2(fz,Y); PRINT(); PRINT(lx(1)+" ft "+lx(2)+ " "+lx(3)+" in"); PRINT("-"); PRINT(ly(1)+" ft "+ly(2)+ " "+ly(3)+" in"); PRINT("="); PRINT(lz(1)+" ft "+lz(2)+ " "+lz(3)+" in"); WAIT(0); END; // multiply by scalar IF ch==3 THEN INPUT(S,"Enter Scalar"); fz:=fx*S; lx:=sub2(fx,Y); lz:=sub2(fz,Y); PRINT(); PRINT(lx(1)+" ft "+lx(2)+ " "+lx(3)+" in"); PRINT("*"); PRINT(S); PRINT("="); PRINT(lz(1)+" ft "+lz(2)+ " "+lz(3)+" in"); WAIT(0); END; // divide by scalar IF ch==4 THEN INPUT(S,"Enter Scalar"); fz:=fx/S; lx:=sub2(fx,Y); lz:=sub2(fz,Y); PRINT(); PRINT(lx(1)+" ft "+lx(2)+ " "+lx(3)+" in"); PRINT("/"); PRINT(S); PRINT("="); PRINT(lz(1)+" ft "+lz(2)+ " "+lz(3)+" in"); WAIT(0); END; // multiply to area IF ch==5 THEN fy:=sub1(); fz:=fx*fy; fz:=ROUND(fz,6); lx:=sub2(fx,Y); ly:=sub2(fy,Y); aflag:=1; PRINT(); PRINT(lx(1)+" ft "+lx(2)+ " "+lx(3)+" in"); PRINT("*"); PRINT(ly(1)+" ft "+ly(2)+ " "+ly(3)+" in"); PRINT("="); PRINT(fz+" ft^2"); WAIT(0); END; // divide from area IF ch==6 THEN fy:=sub1(); fz:=fx/fy; ly:=sub2(fy,Y); lz:=sub2(fz,Y); aflag:=0; PRINT(); PRINT(fx+" ft^2"); PRINT("/"); PRINT(ly(1)+" ft "+ly(2)+ " "+ly(3)+" in"); PRINT("="); PRINT(lz(1)+" ft "+lz(2)+ " "+lz(3)+" in"); WAIT(0); END; // diagonal from area IF ch==7 THEN fz:=√(fx); lz:=sub2(fz,Y); aflag:=0; PRINT(); PRINT("√"+fx+" ft^2"); PRINT("="); PRINT(lz(1)+" ft "+lz(2)+ " "+lz(3)+" in"); WAIT(0); END; // change accruacy settings IF ch==8 THEN INPUT({{Y, {2,4,8,16,32,64}}}, "ACCURACY DESIRED","/"); Y:=2^Y; END; END; END; // feet-inch-fraction entry sub1() BEGIN LOCAL f,i,s,n; INPUT({f,i,s,{n, {2,4,8,16,32,64}}}, "ENTRY", {"Feet: ","Inch: ", "Frac: ","/"}); RETURN f+(i+s/(2^n))/12; END; // convert to feet-inch sub2(x,y) BEGIN LOCAL f,i,s,t; f:=IP(x); i:=IP(FP(x)*12); s:=ROUND(FP(FP(x)*12)*y,0); t:=QPI(s/y); RETURN {f,i,t}; END;``` Thanks for the explanation of the SYSEVAL commands. Eddie **I made a correction in the division by scalar section. The above code is now correct. RE: Need to convert FIF49 to Prime version - Mikebike - 06-21-2018 01:03 PM Eddie, thank you for your work. I will be putting the software that came with the Prime on my PC at home and then adding this code to a new app and give it a go. Spent most of the first few days with the Prime getting used to the layout and the CAS aspects of it. I really like this HP Prime and it seems to be an excellent model to move up to from my older calculator. Is the CONN4X program what I need to use to transfer this code onto my Prime? RE: Need to convert FIF49 to Prime version - Eddie W. Shore - 06-21-2018 07:49 PM (06-21-2018 01:03 PM)Mikebike Wrote:  Eddie, thank you for your work. I will be putting the software that came with the Prime on my PC at home and then adding this code to a new app and give it a go. Spent most of the first few days with the Prime getting used to the layout and the CAS aspects of it. I really like this HP Prime and it seems to be an excellent model to move up to from my older calculator. Is the CONN4X program what I need to use to transfer this code onto my Prime? Thank you, much appreciated. For HP Prime, you will need to use the Connectivity Kit. The kit can be found on this thread: http://www.hpmuseum.org/forum/thread-10219.html RE: Need to convert FIF49 to Prime version - Mikebike - 06-22-2018 01:58 AM I got the Connectivity kit and made a new program and posted in your code but I may have pasted it in there incorrectly. It gave me a syntax error. I think I pasted it in and left some commands that need to be taken out. The code I have is this... 1BEGIN 2sub1(); 3sub2(); 4 5 6EXPORT FTIN() 7BEGIN 8// 2018-06-21 EWS 9 10// initialization 11LOCAL fx,fy,fz,ch; 12LOCAL lx,ly,lz,Y,S; 13LOCAL aflag,str,dh; All the rest of the code and then At the End I have 221f:=IP(x); 222i:=IP(FP(x)*12); 223s:=ROUND(FP(FP(x)*12)*y,0); 224t:=QPI(s/y); 225RETURN {f,i,t}; 226END; 227 What dod I need to delete or change? RE: Need to convert FIF49 to Prime version - grsbanks - 06-22-2018 06:39 AM Take out the line numbers. They are not needed. RE: Need to convert FIF49 to Prime version - Stevetuc - 06-22-2018 07:02 AM (06-22-2018 06:39 AM)grsbanks Wrote:  Take out the line numbers. They are not needed. Also the BEGIN on very first line. Its not needed before the sub calls and will cause an error. RE: Need to convert FIF49 to Prime version - DrD - 06-22-2018 10:57 AM 1. Create a new program in the connectivity kit called FTIN. 2. In the new program's ENTRY box, select EVERYTHING and delete it. 3. Re-visit Eddie's code block in his posting. SELECT all of his code, COPY it and then PASTE it into the connectivity kit program entry box. 4. Select the Save, or the Save All Icon (The 3.5" disc in the connectivity kit's menu bar) to save it to the emulator, or other connected devices -OR- DRAG the program's name from the left calculator pane, and DROP it on any other connected calculator. The program should be usable at this point. If it doesn't run, use [Shift] [Programs], find the FTIN program, and click on it. Select the soft menu [Check], where issues can be identified. Creating programs will become familiar and quite useful with practice. RE: Need to convert FIF49 to Prime version - Mikebike - 06-22-2018 12:19 PM That worked. I did what you said and the program works. I will be using it and getting used to how it operates. I will be looking at the code to learn from it and see how it all works. Eddie, thanks for putting that together so quickly!!! One question, on the Prime, is it possible to customize the soft keys that are on the screen or are these "owned" by the operating system and non customizeable even in your own program? RE: Need to convert FIF49 to Prime version - Eddie W. Shore - 06-22-2018 01:07 PM It is possible to customize soft keys. This is done through the DRAWMENU command and use the MOUSE keys. On the link here I have two programs that uses soft menus: https://edspi31415.blogspot.com/2014/04/hp-prime-ec-and-blotch-two-programs.html Also here is an updated FTIN: I corrected a spelling error and re-labeled on the of the options. . Code: ``` sub1(); sub2(); EXPORT FTIN() BEGIN // 2018-06-21 EWS // initialization LOCAL fx,fy,fz,ch; LOCAL lx,ly,lz,Y,S; LOCAL aflag,str,dh; INPUT({{Y, {2,4,8,16,32,64}}}, "ACCURACY DESIRED","/"); Y:=2^Y; // initial entry CHOOSE(dh,"Initial Units", {"ft-in","ft^2"}); IF dh==1 THEN fx:=sub1(); fz:=fx; aflag:=0; ELSE INPUT(fx,"Enter Area","ft^2:"); fz:=fx; aflag:=1; END; WHILE ch≠9 DO fx:=fz; // string for fz IF aflag==0 THEN lx:=sub2(fx,Y); str:=STRING(lx(1))+" ft "+ STRING(lx(2))+" "+ STRING(lx(3))+" in"; ELSE str:=STRING(fx)+" ft^2"; END; CHOOSE(ch,str, {"Add ft-in", "Subtract ft-in", "Multiply by scalar", "Divide by scalar", "Multiply to area", "Divide from area", "Square Root from area", "Change accuracy settings", "Quit"}); // add ft-in IF ch==1 THEN fy:=sub1(); fz:=fx+fy; lx:=sub2(fx,Y); ly:=sub2(fy,Y); lz:=sub2(fz,Y); PRINT(); PRINT(lx(1)+" ft "+lx(2)+ " "+lx(3)+" in"); PRINT("+"); PRINT(ly(1)+" ft "+ly(2)+ " "+ly(3)+" in"); PRINT("="); PRINT(lz(1)+" ft "+lz(2)+ " "+lz(3)+" in"); WAIT(0); END; // subtract ft-in IF ch==2 THEN fy:=sub1(); fz:=fx-fy; lx:=sub2(fx,Y); ly:=sub2(fy,Y); lz:=sub2(fz,Y); PRINT(); PRINT(lx(1)+" ft "+lx(2)+ " "+lx(3)+" in"); PRINT("-"); PRINT(ly(1)+" ft "+ly(2)+ " "+ly(3)+" in"); PRINT("="); PRINT(lz(1)+" ft "+lz(2)+ " "+lz(3)+" in"); WAIT(0); END; // multiply by scalar IF ch==3 THEN INPUT(S,"Enter Scalar"); fz:=fx*S; lx:=sub2(fx,Y); lz:=sub2(fz,Y); PRINT(); PRINT(lx(1)+" ft "+lx(2)+ " "+lx(3)+" in"); PRINT("*"); PRINT(S); PRINT("="); PRINT(lz(1)+" ft "+lz(2)+ " "+lz(3)+" in"); WAIT(0); END; // divide by scalar IF ch==4 THEN INPUT(S,"Enter Scalar"); fz:=fx/S; lx:=sub2(fx,Y); lz:=sub2(fz,Y); PRINT(); PRINT(lx(1)+" ft "+lx(2)+ " "+lx(3)+" in"); PRINT("/"); PRINT(S); PRINT("="); PRINT(lz(1)+" ft "+lz(2)+ " "+lz(3)+" in"); WAIT(0); END; // multiply to area IF ch==5 THEN fy:=sub1(); fz:=fx*fy; fz:=ROUND(fz,6); lx:=sub2(fx,Y); ly:=sub2(fy,Y); aflag:=1; PRINT(); PRINT(lx(1)+" ft "+lx(2)+ " "+lx(3)+" in"); PRINT("*"); PRINT(ly(1)+" ft "+ly(2)+ " "+ly(3)+" in"); PRINT("="); PRINT(fz+" ft^2"); WAIT(0); END; // divide from area IF ch==6 THEN fy:=sub1(); fz:=fx/fy; ly:=sub2(fy,Y); lz:=sub2(fz,Y); aflag:=0; PRINT(); PRINT(fx+" ft^2"); PRINT("/"); PRINT(ly(1)+" ft "+ly(2)+ " "+ly(3)+" in"); PRINT("="); PRINT(lz(1)+" ft "+lz(2)+ " "+lz(3)+" in"); WAIT(0); END; // square root from area IF ch==7 THEN fz:=√(fx); lz:=sub2(fz,Y); aflag:=0; PRINT(); PRINT("√"+fx+" ft^2"); PRINT("="); PRINT(lz(1)+" ft "+lz(2)+ " "+lz(3)+" in"); WAIT(0); END; // change accruacy settings IF ch==8 THEN INPUT({{Y, {2,4,8,16,32,64}}}, "ACCURACY DESIRED","/"); Y:=2^Y; END; END; END; // feet-inch-fraction entry sub1() BEGIN LOCAL f,i,s,n; INPUT({f,i,s,{n, {2,4,8,16,32,64}}}, "ENTRY", {"Feet: ","Inch: ", "Frac: ","/"}); RETURN f+(i+s/(2^n))/12; END; // convert to feet-inch sub2(x,y) BEGIN LOCAL f,i,s,t; f:=IP(x); i:=IP(FP(x)*12); s:=ROUND(FP(FP(x)*12)*y,0); t:=QPI(s/y); RETURN {f,i,t}; END;``` RE: Need to convert FIF49 to Prime version - DrD - 06-22-2018 04:44 PM Programs similar to Eddie's FTIN and FIF49, require a lot of steps to get through a related problem, such as this one, taken from the provided examples in FIF49: A 15' 9-1/2" wall is to have three 14-5/8" windows installed equally spaced. What is the horizontal space between the windows? To solve the problem you multiply the window width times three, subtract the total window width from the wall length, and divide the space remaining by four. Press L1: FIF Remarks FIF, FIF2 - - Opens FIF environment 15, FT or ENTER 15.00 15' 0" Wall width feet 9, IN 15.75 15' 9" Adds inches 1, /2 15.79 15' 9" 1/2 Adds halves 0, FT 0.00 0' 0" Assumes FIX 2 mode 14, IN 1.17 1' 2" L1: Must have a number 5, /8 1.22 1' 2" 5/8 Adds 5/8 inches 3, X 3.66 3' 7" 7/8 Width of 3 windows - 12.14 12' 1" 5/8 Wall minus windows 4, ö 3.03 3' 0" 7/16 Space between windows It's easier to enter the terms of this problem directly into the hp prime command line: (15_(ft)+(9+(1/2))_(inch)-(3*(14+(5/8))_(inch)))/4; // ==> 3.03385416668_(ft); FP(CAS.left(3.03385416668_(ft))) * 12; // to extract the fractional inches... Multiply by the architectural fraction desired, to get the fractional inch measure, (round accordingly): ROUND(FP(CAS.left(3.03385416668_(ft))) * 12 * 16,0); // For sixteenths ==> 3' 7/16" So, just entering the terms of the problem, (with appropriate units), is actually easier than using the program ... not to mention creating the program in the first place! -Dale- RE: Need to convert FIF49 to Prime version - BruceH - 06-24-2018 01:37 PM There is an alternate approach which is to use 3 element lists to represent feet, inches and fractions of inches. For example, the 15' 9-1/2" wall from earlier is entered as {15,9,1/2} (which displays as {15,9,0.5} but pressing [a b/c] turns the 0.5 back to a fraction). Addition, subtraction and multiplication by a constant work as expected e.g. '3 * {0,14,5/8}' gives {0,42,1.875} which then just needs to be 'normalised'. The function FIF does this normalisation: Code: ```EXPORT FIF(m) BEGIN   LOCAL res := {0,0,0};   LOCAL in;   in := ΣLIST(m * {12,1,1});   res(1) := IP(in/12);   res(2) := IP(in MOD 12);   res(3) := FP(in);   RETURN res; END;``` The full windows-in-wall example can be calculated as: ({15,9,1/2}-3*{0,14,5/8})/4 -> {3.75,-8.25,-0.34375} and then FIF(Ans) -> {3, 0, 13/32} It is an easy matter to modify the code to use fixed 8ths or 16ths for the third value in the list if so desired. RE: Need to convert FIF49 to Prime version - DrD - 06-24-2018 03:38 PM Thats cool! You might like to keep the units and fraction format: Code: ``` // Enter list of feet, inches, fractional inches AND architectural precision! EXPORT FIF(m,a) BEGIN   LOCAL res := {0,0,0};   LOCAL in;   in := ΣLIST(m * {12,1,1});   res(1) := IP(in/12);   res(2) := IP(in MOD 12);   res(3) := ROUND(FP(in)*a,0)/a;  //  Adjust for architectural units    RETURN exact(res * {1_(ft),1_(inch),1_(inch)}); // Return with units and fractions END;``` Shortened version: Code: ``` //                                 From BruceH on MoHPC //                         modified for architectural fraction // //                                     FIF(m,a) //                                    6/24/2018 //                                       drd // // INPUTS:  Use 3 element list to represent feet, inches and fractions of inches. // // A 15' 9-1/2" wall is to have three 14-5/8" windows installed equally spaced. What is the horizontal space between the windows?  // To solve the problem you multiply the window width times three, subtract the total window width from the wall length, then // divide the space remaining by four. // // The full windows-in-wall example can be calculated as: ({15,9,1/2}-3*{0,14,5/8})/4 -> {3.75,-8.25,-0.34375} and then FIF(Ans) -> {3, 0, 13/32} // For example, the 15' 9-1/2" wall from earlier is entered as {15,9,1/2} (which displays as {15,9,0.5} but pressing [a b/c] turns the 0.5 back to a fraction). // Addition, subtraction and multiplication by a constant work as expected e.g. '3 * {0,14,5/8}' gives {0,42,1.875} This function FIF(m,a) does this // Enter list of feet, inches, fractional inches AND architectural precision! EXPORT FIF(m,a) BEGIN   LOCAL in;   in := ΣLIST(m * {12,1,1});   RETURN exact({IP(in/12),IP(in MOD 12),ROUND(FP(in)*a,0)/a} * {1_(ft),1_(inch),1_(inch)}); //  Adjust for architectural fraction END;``` [attachment=6027] -Dale- RE: Need to convert FIF49 to Prime version - Didier Lachieze - 06-24-2018 04:41 PM 7.00/16.00 = 13.00/32.00 ??? RE: Need to convert FIF49 to Prime version - DrD - 06-24-2018 06:31 PM (06-24-2018 04:41 PM)Didier Lachieze Wrote:  7.00/16.00 = 13.00/32.00 ??? excuses := { To the nearest architectural fraction, Take or leave the cut line?, Offset for pencil thickness?, Coefficient of expansion?, Delta temperature?, Machine tolerance?, Blade tolerance?, It looks better than 6+1/2/16 = 13/32?, It looks better than 6.5/16 = 13/32?, Rounding effect, }; Choose one, or more ... 