1 Reply Latest reply on Feb 27, 2009 11:29 PM by comment_1

    Newb trying to create fractions from decimals...



      Newb trying to create fractions from decimals...


      I'm a prepress operator for a printing company.  My company uses an older version of Filemaker Pro (v6).  I'm been drafted to build a cover layout and fill it with calculations so that our service reps only have to enter dimensions for a cover and it's automatically calculated.  Now, writing code is very far from my strong suit.  I've been searching all over forums and the web, and what I find I either need to a) spend money to read/watch tutorials that *might* help, b) have to copy/paste and alter code, and I wind up with errors saying I have stray characters or undefined fields or c) get answers that apply only to later versions of Filemaker Pro. Any help would be much appreciated.


      Here's what I'm trying to do.


      Variable Fields: X = Page Count, Y = Pages Per Inch

      Within one field, I need to find

      • the result of X/Y
      • have the answer rounded up to the closest 1/32
      • return the answer to the user in fraction form (in lowest form, i.e. 6/32 should read 3/16)
      • have this fraction be readable as a number so it can be used by a later calculation.  


      I'm not sure what's doable, and what's not doable in this version of FileMaker.  If you reply with bits of code, please use the X and Y variables so I can identify where to put my field names.  Thank you in advance!!

        • 1. Re: Newb trying to create fractions from decimals...
             I'd suggest you make this in two steps, otherwise your formula will be utterly unreadable in version 6. The first step is to divide X by Y and round the result to nearest 1/32 (result is Number):

          Round ( X / Y * 32, 0 ) / 32

          Note that here we have no protection against Y being 0 or empty, which will result in an error.

          Let's call the previous result n and move to the second and final step* (result is Text) =

          Case ( Int ( n ) ,  Int ( n ) &  " " )
          Case (
          Mod ( n, 1 ),
          Mod ( n, 1 ) * 2^( Length (  Mod ( n, 1 ) ) - 1 )
          &  "/"  &
          2^( Length (  Mod ( n, 1 ) ) - 1 )

          (*) adapted from http://www.onegasoft.com/tools/commonfractions/index.shtml