StringConstruct ( )

Function stats

Average user rating
234
250
9999
Support
FileMaker 7.0 +
Date posted
20 February 2010
Version
1
Recursive function
No

Author Info
 Chad S.

3 functions

Average Rating None

author_avatar



 

Function overview

Prototype

StringConstruct  ( text;   prefix;   suffix;   altText )


Parameters

text  the text you want to display


prefix  a prefix to the text


suffix  a suffix to the text


altText  an alternate text to show if the primary text is empty


Description

Tags:  Text Parsing   Text  

PURPOSE:    used to concatenated text strings, extremely useful when trying to build natural language text strings.
You can point to a text value, if its empty, only the Alt text will display if provided.
If there is a value for the text the prefix and suffix will show, if provided.

PARAMETERS:
text - the text you want to display
prefix - a prefix to the text
suffix - a suffix to the text
altText - an alternate text to show if the primary text is empty

IMPORTANT NOTES:    remember if you want any or all the parameters to be empty, just use "" (double quotes)


EXAMPLES:
Student::Name = "Joe"
Student::Gender = "male"
Student::Name & " is " & StringConstruct ( Student::Gender; "" ; "." ; "a person." )
Returns "Joe is male."

Student::Name = "Joe"
Student::Gender = ""
Student::Name & " is " & StringConstruct ( Student::Gender ; "" ; "." ; "a person." )
returns "Joe is a person."

Student::Name = "Joe"
Student::Gender = "male"
Student::Age = 18
Student::Name & " is " & StringConstruct ( Student::Age; "a "; " year old" & StringConstruct ( Student::Gender; " "; "."; " person." ); StringConstruct ( Student::Gender; ""; "."; "a person." ) )
Returns:
"Joe is a 18 year old male."

Student::Name = "Joe"
Student::Gender = ""
Student::Age = 18
Student::Name & " is " & StringConstruct ( Student::Age; "an "; " year old" & StringConstruct ( Student::Gender; " "; "."; " person." ); StringConstruct ( Student::Gender; ""; "."; "a person." ) )
Returns:
"Joe is a 18 year old person."

Student::Name = "Joe"
Student::Gender = ""
Student::Age = ""
Student::Name & " is " & StringConstruct ( Student::Age; "an "; " year old" & StringConstruct ( Student::Gender; " " ; "." ; " person." ) ; StringConstruct ( Student::Gender ; "" ; "." ; "a person." ) )
Returns:
"Joe is a person."

Student::Name = "Joe"
Student::Gender = "male"
Student::Age = 18
Student::Name & " is " & StringConstruct ( Student::Age ; "an " ; " year old" & StringConstruct ( Student::Gender ; " " ; "." ; " person." ) ; StringConstruct ( Student::Gender; "" ; "." ; "a person." ) )
Returns:
"Joe is male."

Examples

Sample input

Student::Name & " is " & StringConstruct ( Student::Age; "an "; " year old" & StringConstruct ( Student::Gender; " "; "."; " person." ); StringConstruct ( Student::Gender; ""; "."; "a person." ) )


Sample output

Joe is an 18 year old male.

 

Function code

/*
NAME:    StringConstruct ( text ; prefix ; suffix ; altText )
CREATORNAME:    Chad Sager, IT Solutions Consulting, Inc.
CREATOREMAIL:    chad.sager@itsolutions-inc.com
DATE CREATED:     2010-02-18
DATE LASTMODIFIED:     2010-02-18

PURPOSE:    used to concatenated text strings, extremely useful when trying to build natural language text strings.
You can point to a text value, if its empty, only the Alt text will display if provided.
If there is a value for the text the prefix and suffix will show, if provided.

PARAMETERS:
text - the text you want to display
prefix - a prefix to the text
suffix - a suffix to the text
altText - an alternate text to show if the primary text is empty

IMPORTANT NOTES:    remember if you want any or all the parameters to be empty, just use "" (double quotes)


EXAMPLES:
Student::Name = "Joe"
Student::Gender = "male"
Student::Name & " is " & StringConstruct ( Student::Gender; "" ; "." ; "a person." )
Returns "Joe is male."

Student::Name = "Joe"
Student::Gender = ""
Student::Name & " is " & StringConstruct ( Student::Gender ; "" ; "." ; "a person." )
returns "Joe is a person."

Student::Name = "Joe"
Student::Gender = "male"
Student::Age = 18
Student::Name & " is " & StringConstruct ( Student::Age; "a "; " year old" & StringConstruct ( Student::Gender; " "; "."; " person." ); StringConstruct ( Student::Gender; ""; "."; "a person." ) )
Returns:
"Joe is a 18 year old male."

Student::Name = "Joe"
Student::Gender = ""
Student::Age = 18
Student::Name & " is " & StringConstruct ( Student::Age; "an "; " year old" & StringConstruct ( Student::Gender; " "; "."; " person." ); StringConstruct ( Student::Gender; ""; "."; "a person." ) )
Returns:
"Joe is a 18 year old person."

Student::Name = "Joe"
Student::Gender = ""
Student::Age = ""
Student::Name & " is " & StringConstruct ( Student::Age; "an "; " year old" & StringConstruct ( Student::Gender; " " ; "." ; " person." ) ; StringConstruct ( Student::Gender ; "" ; "." ; "a person." ) )
Returns:
"Joe is a person."

Student::Name = "Joe"
Student::Gender = "male"
Student::Age = 18
Student::Name & " is " & StringConstruct ( Student::Age ; "an " ; " year old" & StringConstruct ( Student::Gender ; " " ; "." ; " person." ) ; StringConstruct ( Student::Gender; "" ; "." ; "a person." ) )
Returns:
"Joe is male."


*/



Case (
    not IsEmpty ( text ) ; prefix & text & suffix ;
    altText
)

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

    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/250

    Prototype: StringConstruct( text; prefix; suffix; altText )
    Function Author: Chad S. (http://www.fmfunctions.com/mid/234)
    Last updated: 20 February 2010
    Version: 1

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

 

 

 

 

 

 

 

Top Tags

Text Parsing  (33)
List  (31)
Date  (28)
XML  (26)
Format  (23)
Sql  (22)
Dev  (20)
Debug  (17)
Interface  (15)
Layout  (15)
Text  (14)
Variables  (12)
Layout Objects  (11)
Filter  (11)
Design  (10)
Array  (7)