Software Venture Consulting
ToMarket

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


Brian Dunning
Contact me | vCard


Brian on CNN
Brian on CNN


Brian on CBS Radio


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

Apply ( function ; value )

Rate this function:  

RatingRatingRatingRatingRating
  Average rating: 3.7  (9 votes)
  Discuss this Custom Function

Debi Fuchs, Aptworks Consulting
http://www.aptworks.com

Apply an "inline" function to a value, handling the value either as a number/expression or as text.

Sample Input:
Let(
sq_plus = "[t]*[t]+[t]";
Apply(sq_plus; 3) +
Apply(sq_plus; 4) +
Apply(sq_plus; 5)
)
Sample Output:
62


 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:

CUSTOM FUNCTION: Apply ( function ; value )
© 2008 Debi Fuchs of Aptworks Consulting, debi@aptworks.com

Apply an "inline" function to a value, handling the value either as a number/expression or as text.

BASIC EXAMPLE:

Let(
square = "[n]*[n]";
Apply( square; 3 ) + Apply( square; 4 ) + Apply( square; "2+3" )
) // --> 50

MULTIPLE ARGUMENT EXAMPLE:

Let(
exp = "GetValue([t];1) ^ GetValue([t];2)";
Apply( exp; List(2;5) ) + Apply( exp; List(3;4) )
) // --> 113

RECURSIVE EXAMPLE:

Let(
$factorial_fn= "if([n]=0;1;[n]*Apply($factorial_fn; [n]-1))";
Apply($factorial_fn; 5)
) // --> 120

MUTUALLY RECURSIVE EXAMPLE:

Let(
[
$even_fn = "if([n]=0; 1; Apply($odd_fn; [n]-1))";
$odd_fn = "if([n]=0; 0; Apply($even_fn; [n]-1))"
];
Apply($even_fn; 8)
) // --> 1


CREDITS: Thanks to Agnès Barouh for the idea of the "[n]" style function call syntax.

USAGE: Return the results of evaluating the string "function", assigning to placeholder "[t]" or "[n]" the given "value". Use "[t]" to treat the value as text; Use "[n]" to evaluate it before application. (Note that the use of "[t]" vs. "[n]" does not directly influence the "type" of the result...only the treatment of the input value.) Use "[n]" over "[t]" where possible, as this is faster; Do NOT use BOTH "[n]" and "[t]" placeholders (or BOTH "[t]"and "evaluate([t])" in one function, as this is very, very slow.

EXAMPLES:

Apply("[n] & 4"; 01+2)
// --> evaluate(3 & 4) --> "34"

Apply("[t] & 4"; 01+2)
// --> evaluate("3" & 4) --> "34"

Apply("[n] & 4"; "01+2")
// --> evaluate(01+2 & 4) --> "34"

Apply("[t] & 4"; "01+2")
// --> evaluate("01+2" & 4) --> "01+24"

Apply("[n] + 4"; "01+2")
// --> 7

Apply("[t] + 4"; "01+2")
// --> 16

Apply("GetAsDate([t])+30"; Date(1;1;2000))
// --> GetAsDate("1/1/2000") + 30 --> 1/31/2000

Apply("GetAsDate([n])+30"; "Date(1;1;2000)")
// --> GetAsDate(Date(1;1;2000)) + 30 --> 1/31/2000

Apply("GetAsDate([n])+30"; Date(1;1;2000))
// --> GetAsDate(1/1/2000) + 30 --> ?

Apply("GetAsDate([n])+30"; GetAsNumber(Date(1;1;2000)))
// --> GetAsDate(730120)+30 --> 1/31/2000

Apply("[t] + [n]"; "01+2")
// --> "01+2" + 01+2 --> 15


IMPLEMENTATION: Evaluate the result of substituting the input into an evaluated "Let" statement, treating the input as EITHER text or a number/expression.

NOTE: See "ApplyToRange" to apply a function to a range of numbers and "ApplyToList" to apply a function to each element of a list.

LAST MODIFIED: 11-AUG-2008 by Debi Fuchs of Aptworks Consulting

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:

There are no comments yet. Be the first to post 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 8 + 2 =
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. webviewer_button ( content; textCol; bgCol )
  (Wed, Mar 03, 11:18am)
2. RemoveCommonValues ( Array ; ComparisonArray )
  (Wed, Feb 24, 9:39pm)
3. DistanceGeoCoord ( Lat1deg ; Lat1mm ; Lat1ss ; Lon1deg ; Lon1mm ; Lon1ss ; Lat2deg ; Lat2mm ; Lat2ss ; Lon2deg ; Lon2mm ; Lon2ss ; U ; Version )
  (Wed, Feb 24, 2:20pm)
4. fnGoogleLineChart ( chtitle ; xtitle ; ytitle ; xfield ; yfield ; color )
  (Tue, Feb 23, 1:30pm)
5. StringConstruct ( text ; prefix ; suffix ; altText )
  (Fri, Feb 19, 10:57am)
6. ShowValueCascade ( fields ; altText )
  (Fri, Feb 19, 10:44am)
7. ShowValue ( text; altText )
  (Fri, Feb 19, 10:28am)
8. timeFormat ( thetime ; leader )
  (Wed, Feb 17, 7:44pm)

RSS Feed of Custom Functions