Software Venture Consulting

FileMaker Pro downloads & Resources
FileMaker Custom Functions
FileMaker Web Viewer Examples
FileMaker Pro & Lasso Consulting
Training
FileMaker Books
FileMaker Articles
FileMaker Error Reference

Free Web Tools
Free FileMaker Tools

Personal Pages
Videos
Adventures
Links

Shopping Cart
Shopping Cart

Search:

Free Newsletter
Signup


Contact


Privacy Policy



FileMaker is a registered trademark of FileMaker, Inc. in the U.S. and other countries.

 

 FileMaker Pro Custom Functions

List  |  Show Random  |  Upload  |  Add This to Your Site

MinValue ( lst ; value )

Rate this function:  

RatingRatingRatingRatingRating
  Average rating: 3.9  (30 votes)
  Discuss this Custom Function

Theo Ros, n/a
n/a

Returns the smallest value in the list

Sample Input:
MinValue ( "apple¶grape¶banana" ; "" )
Sample Output:
apple


 Then copy & paste into FileMaker Advanced's Edit Custom Function window.

Click here to copy To Clip Manager if you have myFMbutler's Clip Manager installed

Description:

Returns the smallest value in the list

Syntax: MinValue ( list ; value )
In: lst - the return delimited list to search
value - the value currently compared

Return type: Text

MinValue ( "apple¶grape¶banana" ; "" ) --> "apple"

Always start the function off with parameter 'value' = ""

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

This is my Custom Function and I want to edit it

Discuss:

Initially had troubles because the syntax uses a reserved word "List" (changed to listy as needed)

and

current = Substitute ( value ; "¶" ; "" )

looks like it should be ..

current = Substitute ( currentvalue ; "¶" ; "" )

after making those tweaks, it looks to be working just fine.

Dwayne Wright, Seattle
August 18, 2010 1:36pm

Thanks Dwayne for that!

I've updated this function and also the MaxValue function to use "lst" as parameter name instead of "list".

As for the part where it says: current = Substitute ( value ; "¶" ; "" )

that one was correct, because i used the function with the second parameter actually being called "value".

Mistakingly however in the descriptive part (Syntax:) i called it currentValue.
I changed that aswell

Theo Ros, The Netherlands
August 19, 2010 12:42am

Hi,

I tried to understand and get this to work by renaming
variables, but the results are bogus.

Can you explain what is going on?


/* --------------------------------------------------------------------------- -----
Returns the smallest value in the lst

Syntax: ShortestString ( lst ; InitStr )
In: lst - the return delimited list to search
InitStr - the value currently compared

Return type: Text

ShortestString ( "apple¶grape¶banana" ; "" ) --> "apple"

Always start the function off with parameter 'InitStr' = ""

Theo Ros
* updated augustus 9, 2010: changed parameter name "list" to "lst"
thanks to Dwayne Wright
------------------------------------------------------------------- ------------- */

// If our list contains more than zero elements
If(ValueCount(lst) ;

// Then process:
// Initialize some variables:
Let([
// Select the next value, and strip out carriage return:
CompareStr = Substitute(LeftValues(lst ; 1 ); "¶" ; "" );

// Strip out carriage return:
CurStr = Substitute(InitStr ; "¶" ; "" );

// Set chunk of remaining strings:
RemainderStr = MiddleValues( lst ; 2 ; 9999999999 ) ;

// Which is the smallest string?
SmallStr = Case(IsEmpty(CurStr); CompareStr;
Length(CompareStr) < Length(CurStr) ; CompareStr;
CurStr
) // End Case
]; // End Let

// If there are any strings remaining, recurse on this remainder:
If (ValueCount (RemainderStr); ShortestString(RemainderStr ;

Westenra, Moldova
May 09, 2016 9:11pm

Hi,

first of, changing variable names is always a good way of figuring out how things work.
In your version, i can some things wrong.

First: you have mistakenly changed the comparison "next < current" into "Length(CompareStr) < Length(CurStr)" which is not correct, because now suddenly you do not compare the values themselves, but their length. This is not what the function is meant for.

Second: In the last part of the function, you have replaced the function name "MinValue" into a non-existing one called "ShortestString". MinValue is NOT a variable name, but the name of this function, so you should not have renamed that.
(what happens there is that the function calls itself for as long as the list has values. This is called Recursion)

Third: i believe you have left out the last part of the function, so now the final If (and also the function as a whole) is not complete.
Your If now is like this:
If (ValueCount (RemainderStr); ShortestString(RemainderStr ;

where it shoud be
If ( ValueCount ( rest ) ; MinValue ( rest ; low ) ; low )

Finally, to close the function after this If, you need to add two extra brackets:

) // End Let
) // End top If


Just one final tip: because in FileMaker all functions start with Capitals, i like to name my variables in camel-case, so they all start with lowercase characters. This helps in recognizing if something is a function name or a variable. ("compareStr", "curStr", etc.)

Hope this helps.

Cheers,
Theo

Theo Ros, Hilversum, The Netherlands
May 10, 2016 12:13am

Make a comment about this Custom Function (please try to keep it brief & to the point). Anyone can post:

Your Name:
City/Location:
Comment:
characters left. If you paste in more than 1500 characters, it will be truncated. Discuss the function - advertisements and other useless posts will be deleted.
Answer 6 + 1 =
Search for Custom Functions:

Custom Functions Widget
Download the Custom Function Dashboard Widget for OS X
Keep all the latest Custom Functions right at your fingertips!

Newest Custom Functions:

1. decFromHex ( hexValue )
  (Mon, Oct 16, 12:34pm)
2. MonthYearList ( startmonth ; startyear ; numbermonth ; short )
  (Mon, Oct 16, 3:38am)
3. ErrorDescription ( errorNumber )
  (Wed, Sep 27, 2:51am)
4. decodeEntities (text)
  (Wed, Sep 27, 1:22am)
5. HexidecimalToNumber ( HexidecimalValue ; counter )
  (Mon, Sep 25, 12:39pm)
6. FixedFieldConverter ( Fieldname ; f1 ; f2 ; f3 ; f4 ; f5 ; f6 ; f7 ; f8 ; f9 ; f10 ; f11 ; f12 ; f13 ; f14 ; f15 ; f16 ; f17 ; f18 ; f1
  (Fri, Sep 15, 12:34pm)
7. ShannonEntropy ( text )
  (Thu, Sep 07, 5:59am)
8. LetterCount ( text ; summary )
  (Thu, Sep 07, 5:53am)

RSS Feed of Custom Functions