listToCommaSep ( )

Function stats

Average user rating
39
297
9999
Support
FileMaker 8.5 +
Date posted
09 February 2011
Version
1
Recursive function
No

Author Info
 Ender

4 functions

Average Rating None

author_avatar



 

Function overview

Prototype

listToCommaSep  ( theList )


Parameters

theList  


Description

Tags:  Text   Interface  

Convert return delimited list to a comma separated list with "and" before the last value.
Automatically removes trailing spaces and one extra line return on the end.

Useful for converting checkboxed values or a list of related items to a human-readable comma-separated list.

Examples

Sample input

John¶Paul¶George ¶Ringo¶


Sample output

John, Paul, George, and Ringo

 

Function code

//listToCommaSep(theList)

//by Ender
//12-9-2010

//Convert return delimited list to a comma separated list with "and" before the last value.
//Automatically removes trailing spaces and one extra line return on the end.


Let(
v = ValueCount(theList);

Case(v>2; Substitute(TrimAll(LeftValues(theList;v-1);0;1);¶;", ") & "and " & Trim(Substitute(RightValues(theList;1);¶;""));
v=2; Trim(Substitute(LeftValues(theList;1);¶;"")) & " and " & Trim(Substitute(RightValues(theList;1);¶;""));
Trim(Substitute(theList;¶;""))
)
)

// ===================================
/*

    This function is published on FileMaker Custom Functions
    to check for updates and provide feedback and bug reports
    please visit http://www.fmfunctions.com/fid/297

    Prototype: listToCommaSep( theList )
    Function Author: Ender (http://www.fmfunctions.com/mid/39)
    Last updated: 09 February 2011
    Version: 1

*/
// ===================================

 

 

 

 

 

 

 

Top Tags

Text Parsing  (31)
Date  (26)
List  (25)
Format  (23)
XML  (22)
Sql  (18)
Dev  (17)
Debug  (14)
Text  (13)
Variables  (12)
Interface  (12)
Layout  (11)
Filter  (10)
Design  (9)
Array  (7)
Layout Objects  (7)