« FILEMAKER: The Get(SortState) Function | Main | FILEMAKER: WordPosition Custom Function By Daniele Raybaudi, ACI »
Friday
Mar262010

Easy Example Of The FileMaker Let Function

From Dwayne Wright PMP
Certified FileMaker Developer

WEB: www.dwaynewright.com
EMAIL: info@dwaynewright.com
TWITTER: dwaynewright
YOUTUBE: FileMakerThoughts

The Let function can be challenging the first time you encounter it. Today I did a quick Let function to parse out the contents between a pair of parenthesis and realized this is a very easy way to explain how a Let function works!

Let([
$start = Position ( text ; "("; 1; 1)+1;
$end = Position ( text ; ")"; 1; 1);
$difference = $end - $start];

Middle ( text; $start; $difference)

The first variable we define tells us where the left parenthesis starts (plus one character), the second variable tells us were the right parenthesis ends and the last variables tells us the number of characters between each parenthesis. That sets up the last calculation that pulls out the desired data with the Middle function!

Reader Comments (3)

Dwayne, it would simplify your example if you used variables with no dollar sign. That way the variables only exist for the purposes of evaluating the calculation.

The $var form creates variables that persist while a script runs, which can be a useful technique, but is not everyday usage in a Let calculation.

March 30, 2010 | Unregistered CommenterTom

I see your point but don't agree with your conclusion (at least in my design cadence). I tend to name my variables like this so I can easily identify them in the data viewer from traditional fields. I also have a habit of defining some $$ (global variables) in Let functions as a get away from multiple Set Variable script steps.

March 31, 2010 | Unregistered CommenterDwayne Wright PMP

My variables are always distinguished by capitalization which can get sticky when doing custom software development, so thank you for the advice. I knew that there was a solution, but I was still struggling to figure one out exactly. SO thank you! :)

February 15, 2012 | Unregistered CommenterAmeliaFilemaker

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Post:
 
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>