Feet & Inch Script
Webb - all rights reserved - ©2004
spacer
Author - Jim Cook
Email: jcook@halcyon.com
Webpage:

Summary: Do arithmetic using feet/inches

Instructions: This script provides the ability to add feet and inches. Two different number formats are provided. Either type f.iinndd or fii.nndd where f is the number of feet, ii is the number of inches, nn is the numerator, and dd is the denominator. For example, five feet, eight and one-half inches is 5.080102 in the first format and 508.0102 in the second format.

Feet & Inch lets you add two measurements, or find the difference between two measurements, as well as the ability to multiply or divide a measurement by a number.

This version is longer than a standard clipboard can hold. I use cliphack to copy it to RPN.


Code:

RPN.2.a \ Feet & Inch
[h]g1 w r2 f m50m02;
[s]#'100'/ChChChChChd1;
[d] g10=0 (0 : #'64' V { g1 H f 0 =0 (:B) H vHV } v );
[f]  { g1 0< (#'64'+r21-r2:B) }  { g1 #'63' > (#'64'-r21+r2:B) } Cd
#'100'/+ #'100'/ r2  #'.5'+w g1 #'12' / #'.05'+ w r2 #'12' %
xa (  r2 m50m02 ++:  #'100' / + r2 #'100' / +);
[t] Cs  xa (d1#'64' r2 g1 0=0 (d11:)/ *r3m12r3 + r2:#'64' r2 g1 0=0
(d11:)/ * r4 m50m02 r4 + m12 r3 + r2);
"Feet & Inch";
"Feet & Inch:Show the version" D'Feet & Inch Version 2.03\Jim
Cook|email|Ok|' ( : D'jcook@halcyon.com|Ok|' d1) ;
~
"+:Add two f&i numbers"?2 Ct r3 Ct r3 +k3 + r2 Cf;
"-:Subtract two f&i numbers" ?2  Ct r3 Ct r3 -k3 r2- g10< (nr2n:r2) Cf;
"*:Multiply f&i by a standard\ number" ?2 r2 Ct g3 * k3 * g1 w r2 f m64  
r3 +  #'.5'+w Cf;
":Divide f&i by a standard\number" ?2  r2 Ct  g3 / k3 r2 / g1 w r2 f
m64  r3 +  #'.5'+w Cf;
~
"_f&i->n: Convert from f&i\format to a standard number"?1Ct #'64' /+;
"_n->f&i: Convert a standard\number to f&i format" ?1 g1 w r2 f m64
#'.5'+w Cf;
~
"Select format: How numbers\are shown. 1 foot 2 and 3/4\is either
102.0304 or 1.020304" D'Do you want to use feet.inches\or
inches.parts?|f.iinndd|fii.nndd|Cancel|' g1 2<(Xa:d1);