Need to convert FIF49 to Prime version
06-21-2018, 12:35 PM (This post was last modified: 06-21-2018 07:47 PM by Eddie W. Shore.)
Post: #7
 Eddie W. Shore Senior Member Posts: 1,539 Joined: Dec 2013
RE: Need to convert FIF49 to Prime version
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:

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.
 « Next Oldest | Next Newest »

 Messages In This Thread Need to convert FIF49 to Prime version - Mikebike - 06-16-2018, 02:23 PM RE: Need to convert FIF49 to Prime version - Eddie W. Shore - 06-18-2018, 12:51 PM RE: Need to convert FIF49 to Prime version - Mikebike - 06-18-2018, 02:16 PM RE: Need to convert FIF49 to Prime version - grsbanks - 06-18-2018, 03:27 PM RE: Need to convert FIF49 to Prime version - Joe Horn - 06-18-2018, 03:29 PM RE: Need to convert FIF49 to Prime version - DavidM - 06-18-2018, 03:42 PM RE: Need to convert FIF49 to Prime version - Eddie W. Shore - 06-21-2018 12:35 PM RE: Need to convert FIF49 to Prime version - Mikebike - 06-21-2018, 01:03 PM RE: Need to convert FIF49 to Prime version - Eddie W. Shore - 06-21-2018, 07:49 PM RE: Need to convert FIF49 to Prime version - Mikebike - 06-22-2018, 01:58 AM RE: Need to convert FIF49 to Prime version - grsbanks - 06-22-2018, 06:39 AM RE: Need to convert FIF49 to Prime version - Stevetuc - 06-22-2018, 07:02 AM RE: Need to convert FIF49 to Prime version - DrD - 06-22-2018, 10:57 AM RE: Need to convert FIF49 to Prime version - Mikebike - 06-22-2018, 12:19 PM RE: Need to convert FIF49 to Prime version - Eddie W. Shore - 06-22-2018, 01:07 PM RE: Need to convert FIF49 to Prime version - DrD - 06-22-2018, 04:44 PM RE: Need to convert FIF49 to Prime version - BruceH - 06-24-2018, 01:37 PM RE: Need to convert FIF49 to Prime version - DrD - 06-24-2018, 03:38 PM RE: Need to convert FIF49 to Prime version - Didier Lachieze - 06-24-2018, 04:41 PM RE: Need to convert FIF49 to Prime version - DrD - 06-24-2018, 06:31 PM RE: Need to convert FIF49 to Prime version - Didier Lachieze - 06-24-2018, 07:22 PM RE: Need to convert FIF49 to Prime version - Mikebike - 06-24-2018, 07:33 PM

User(s) browsing this thread: 1 Guest(s)