Brian Dunning's FileMaker Custom Functions

FractionType ( fraction )

Reports from string if a valid fraction and if improper or mixed number

  Average rating: 5.0 (27 votes) Log in to vote

Brett Buchmiller   Brett Buchmiller
None
www.filemaker.com

Share on Facebook Share on Twitter

  Sample input:
FractionType( "1/2" )

FractionType( "9/8" )

FractionType( "3 7/8" )

FractionType( "3" )
  Sample output:
"Proper"

"Improper"

"Mixed"

"Invalid"

  Function definition: (Copy & paste into FileMaker's Edit Custom Function window)

Part of a library of fraction functions. Reports validity of string to represent fraction and type if valid - Mixed, Proper or improper.

 

Comments

Guy Elsmore-Paddock   Guy Elsmore-Paddock, Inveniem
Jul 12, 2019
Note that this will not work with whole numbers, or numbers that are already decimals.
 
Guy Elsmore-Paddock   Guy Elsmore-Paddock, Inveniem
Jul 12, 2019
Here's a modified version that works for whole numbers (might work with decimals too):
/*
Determines format of fraction and if a valid fraction based on passed text string.

From:
https://www.briandunning.com/cf/1359

Required Functions:
FractionNumerator
FractionDenominator

© Brett Buchmiller 10-2011
Portions © Inveniem 2019 (Whole Number Handling)
*/

If(
IsEmpty(input) or (Position(input; "/"; 1; 1) < 1) or FractionDenominator(input) = 0;

/* Conditional */
If(
/* Conditional */
GetAsNumber(input) = input;

/* When: True (input is already a number) */
"Whole";

/* When: False (input is neither fraction nor a number) */
"Invalid"
);

If(
/* Conditional */
Position(input; " "; 1; 1) > 0;

/* When: True */
"Mixed";

/* When: False */
If(
/* Conditional */
FractionNumerator(input) > FractionDenominator(input);

/* When: True */
"Improper";

/* When: False */
"Proper"
)
)
)
 

Log in to post comments.

 

Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.

Support this website.

This library has been a free commmunity resource for FileMaker users and developers for 20 years. It receives no funding and has no advertisements. If it has helped you out, I'd really appreciate it if you could contribute whatever you think it's worth: