IF statement to replace text
I am trying to substitute some text. For example, if a data field returns 0.375 I want to instead show 3/8. The data field here is [WO-Part."Thickness"]. I would want to use several lines or an array something like:
(IF [WO-Part."Thickness"]==0.375, "3/8",,)
(IF [WO-Part."Thickness"]==0.250, "1/2",,)
Is this even close??
(IF [WO-Part."Thickness"]==0.375, "3/8",,)
(IF [WO-Part."Thickness"]==0.250, "1/2",,)
Is this even close??
Comments
You could compare the text version of your field to "0.375", as it will have a fixed precision, or do something like ABS(<WO-Part."Thickness"> - 0.375) < 0.001
And cheekily add that 0.25 is 1/4 not 1/2 (0.50)!
The code above only catches two cases.
Would it not be better to create a function that presents decimal amounts as the closest vulgar fraction? There are quite a few examples of code to do this, just a google away...
Cheers, Paul
OMG and I do this for a living!
Thanks for the code! I was nowhere close. In our circumstance (still good advice for others down the road), we are very specific with our decimals, i.e. 0.375 is always written exactly that way.