FM Function of the Week: LeftValues, RightValues, and MiddleValues

Having previously ruminated on the Left, Right and Middle functions, then the LeftWords, RightWords, and MiddleWords functions, we’re going to wrap up with a third triad of functions, namely LeftValues, RightValues, and MiddleValues. Before we dig into the functions though, a definition is in order.

When the word “value” appears in the name of a FileMaker function, it has a very specific meaning. A value is a discrete line of text in a return-delimited list. It can take the form of a plain text string, the contents of a field, the contents of a variable, or simply some text that is calculated on the fly. For the purposes of any Value function, any amount of text that starts and/or ends with a line break is a value.

  • Butter
  • 22
  • Eggs
  • White Sugar
  • Brown Sugar
  • 100% Pure Madagascar Vanilla Extract

The items above are a return-separated list and each line is a value to FileMaker (for webpage readability, I’ve included bullets at the start of each line; you don’t actually use bullets in FileMaker). Whether it’s one word, a number, or a combination of the two, they’re all individual values. Even the blank line is a value (granted it’s a null value, but a null value is distinct from no value at all).

the left- right- and middlevalues functions

Like their Left, Right, and Middle brethren, the Values functions require some text, a number signifying how many values to return and, for MiddleValues, the number of the first value to return. Below are three examples of Values functions drawing from a single return-delimited list.

Values function examplesClever and learned readers such as yourself are apt to point out that there’s a GetValue FileMaker function that could arguably render LeftValues, RightValues, and MiddleValues completely redundant and unnecessary. Not so, I say. GetValue can only return one specific value whereas the three Values functions discussed here can obtain any given number of values from a list.

Clever and leaned readers willing to concede the previous point might go on to argue that, given how a return delimited list is by definition a vertical stack, LeftValues and RightValues really ought to have been named TopValues and BottomValues. I’m with you on this one even though such lists can be represented as “value 1¶value 2¶value 3¶value 4”. My hunch is that a judgement call was made in favor of being consistent with the other suites of Left, Right, Middle functions.

 

This entry was posted in FileMaker 13, Function of the Week. Bookmark the permalink.