
1. Re: Calculations using Variables
Mike_Mitchell Jun 28, 2012 12:43 PM (in response to Jason_Farnsworth)Jason 
What I would suggest is to take a look at the Let statement. It allows you to put variables inside your calculation field. For example
Let ( [
var1 = Truncate ( BendDiameter / 12 ; 0 ) ;
var2 = BendDiameter  var1 * 12 ;
var3 = Truncate ( var2 / 1 ; ) ;
{ and so forth }
] ;
rest of calc here
)
HTH
Mike

2. Re: Calculations using Variables
Jason_Farnsworth Jun 28, 2012 12:54 PM (in response to Mike_Mitchell)Mike,
Thank you it works perfectly
Jason

3. Re: Calculations using Variables
comment Jun 28, 2012 3:39 PM (in response to Jason_Farnsworth)Jason_Farnsworth wrote:
What I am trying to accomplish is taking a number that is in inches convert it to feet & inches for a printed display. I can do this with 5 seperate fields one for each each taking 1 step at a time.
I am not sure why this needs to take 5 steps. How about something like =
Div ( number ; 12 ) & " feet " & Mod ( number ; 12 ) & " inches"

4. Re: Calculations using Variables
Jason_Farnsworth Jun 29, 2012 8:32 AM (in response to comment)Micheal,
Your math routine works well except it drops the fraction off the end?
For instance 18.625
I would like to show it as 1' 6 3/4"
Also if I have 9.8125 I would like to show it as 9 13/16"
The real issues is I would like to enter all inches into the database as I collect data  purchasing and our vendors like to see things in feet and inches. So what I am trying to accomplish inch input with feet and inch with fractions printouts.
Currently I am using a fraction function that I made to get the fraction result.
I think that sorting data and looking for data is much simpler if it is standard to one unit.
Thanks
Jason

5. Re: Calculations using Variables
comment Jun 29, 2012 9:06 AM (in response to Jason_Farnsworth)Jason_Farnsworth wrote:
Currently I am using a fraction function that I made to get the fraction result.
Assuming the function works correctly, try =
Let ( [
ft = Div ( number ; 12 ) ;
in = Mod ( number ; 12 )
] ;
Case ( ft ; ft & "' " ) & Case ( in ; Fractions32 ( in ) & "\"" )
)

6. Re: Calculations using Variables
Jason_Farnsworth Jun 29, 2012 9:29 AM (in response to comment)Michael
This calculation is working very strange I am getting ramdon results
47.6875 returns 3' 187/16"
51 returns 4' "
48.375 returns 4' 3/8" which is correct
.5 returns 1/2" which is correct
Jason

7. Re: Calculations using Variables
Jason_Farnsworth Jun 29, 2012 9:57 AM (in response to Jason_Farnsworth)Micheal,
What do you think about this version?
Let ( [
ft = Truncate (DiscriptionData1/12 ; 0) ;
math = DiscriptionData1( ft * 12);
in = Truncate (math/1 ; 0) ;
fra = Fractions32 (math  in)
] ;
Case ( ft ; ft & "' " ) & Case ( in ; in & " " ) & Case ( fra ; fra & "''")
)
In this senerio it seams to be working well with one exception. When I only have feet and inches it doesn't add the " after the inch. If I have a fraction on the it it will add it.
Jason

8. Re: Calculations using Variables
comment Jun 29, 2012 12:27 PM (in response to Jason_Farnsworth)I can't comment without knowing what the Fractions32() function does.

9. Re: Calculations using Variables
Jason_Farnsworth Jun 29, 2012 12:50 PM (in response to comment)Function32
Case(
Round ( Number * 32 ; 0 ) = 32 ; " +1"; //fraction is closer to 1 than 31/32
Mod ( Round ( Number * 32 ; 0 ) ; 2 ) ; Round ( Number * 32 ; 0 ) & "/32" ; // some odd number of 32nds
Mod ( Round ( Number * 16 ; 0 ) ; 2 ) ; Round ( Number * 16 ; 0 ) & "/16" ; // some odd number of 16ths
Mod ( Round ( Number * 8 ; 0 ) ; 2 ) ; Round ( Number * 8 ; 0 ) & "/8" ; // some odd number of 8ths
Mod ( Round ( Number * 4 ; 0 ) ; 2 ) ; Round ( Number * 4 ; 0 ) & "/4" ; // some odd number of 4ths
Mod ( Round ( Number * 2 ; 0 ) ; 2 ) ; Round ( Number * 2 ; 0 ) & "/2" ; // 1/2
"" ) //fraction is closer to 0 than 1/32

10. Re: Calculations using Variables
comment Jun 29, 2012 1:58 PM (in response to Jason_Farnsworth)I see (hopefully). Yes, that looks like it should work  although I would point your atention to the Div(), Mod() and Int() functions.
See also:
http://fmforums.com/forum/topic/39203convertingadecimalintoafractionmeasurement/#entry182759