Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×
The Claris Museum: The Vault of FileMaker Antiquities at Claris Engage 2025! ×

This topic is 6012 days old. Please don't post here. Open a new topic instead.

Recommended Posts

  • Newbies
Posted

Hi Folks! I am a brand new FM7 user! And I am a quick learner... but... I need some fast help with this issue (I know I could figure it out by myself in a week's time, but I need to do it faster).

I need to define a field (in a record) that stores a number in 8ths (fractions) -- like I can easily do in Excel. For example that field in 5 different records might look like this

RECORD 1: 1 1/8

RECORD 2: 3 5/8

RECORD 3: 4 4/8 (notice that's not 1/2!)

RECORD 4: 2 7/8

RECORD 5: 5 3/8

Later... I will have a new layout that will have a field that will total those records (17 4/8)... but that is not as critical to my question today.

And... I want to enter those values exactly as you see them (in 8ths... not 1.125, 3.625, etc.)

I looked at this forum topic, but couldn't figure it out to suit my specific needs:

http://www.fmforums.com/forum/showtopic.php?tid/192065/

Thanks for any help!!!

Posted

I believe the thread you linked to has all the answers - what more do you need to know? There is no way to define a field that way - to Filemaker, "2 7/8" is just a text string with no meaning.

To total the values, you will need a second field that will translate each string into a numerical value that Filemaker can understand.

Posted

Which could look something like this:

Let ( [

@number = Trim(number);

@integer = LeftWords(@number;1);

@integer = If(@integer = @number;0;@integer);

@denominator = Right ( @number ; Length(@number)-Position(@number; "/";1;1 ));

@numerator = Middle ( @number ; Position ( @number ; " "; 1 ; 1 ) ; Position ( @number ; "/"; 1 ; 1 )-Position ( @number ; " "; 1 ; 1 ) )

];



Case(

// no slash, so no fraction

PatternCount(@number;"/")=0;@number;



// too many spaces, so no valid fraction

PatternCount(@number;" ")>1;@number;



// - we have a fraction to parse

@integer + (@numerator/@denominator)

 )

)

You'd probably want to just put validation on your fraction fields, rather than do the preflight checking for slashes etc. I'm basically punting when malformed fractions are entered, and just spitting back the original value, so if you enter "11 space space space 1/8" it won't work.

Michael will probably be disgusted with this and reply with two lines of code that do the same thing :

Posted

Michael will probably be disgusted with this and reply with two lines of code that do the same thing :

True enough - except I already did this in the above-mentioned thread (and it's a one-liner):P

http://www.fmforums.com/forum/showpost.php?post/275809/

As for making sure the data conforms to the format, I'd suggest doing this at the time data is entered. An auto-entered (replace) calc =

TrimAll ( Filter ( entry ; "0123456789 /" ) ; 0 ; 0 )

should take care of the most obvious typos.

This topic is 6012 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.