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: 19 February 2010
Version: 1
*/
// ===================================
/*__LITBR__NAME: StringConstruct ( text ; prefix ; suffix ; altText )__LITBR__CREATORNAME: Chad Sager, IT Solutions Consulting, Inc.__LITBR__CREATOREMAIL: chad.sager@itsolutions-inc.com__LITBR__DATE CREATED: 2010-02-18__LITBR__DATE LASTMODIFIED: 2010-02-18__LITBR____LITBR__PURPOSE: used to concatenated text strings, extremely useful when trying to build natural language text strings. __LITBR__You can point to a text value, if its empty, only the Alt text will display if provided.__LITBR__If there is a value for the text the prefix and suffix will show, if provided.__LITBR____LITBR__PARAMETERS: __LITBR__text - the text you want to display__LITBR__prefix - a prefix to the text__LITBR__suffix - a suffix to the text__LITBR__altText - an alternate text to show if the primary text is empty__LITBR____LITBR__IMPORTANT NOTES: remember if you want any or all the parameters to be empty, just use "" (double quotes)__LITBR____LITBR____LITBR__EXAMPLES:__LITBR__Student::Name = "Joe"__LITBR__Student::Gender = "male"__LITBR__Student::Name & " is " & StringConstruct ( Student::Gender; "" ; "." ; "a person." )__LITBR__Returns "Joe is male." __LITBR____LITBR__Student::Name = "Joe"__LITBR__Student::Gender = ""__LITBR__Student::Name & " is " & StringConstruct ( Student::Gender ; "" ; "." ; "a person." )__LITBR__returns "Joe is a person."__LITBR____LITBR__Student::Name = "Joe"__LITBR__Student::Gender = "male"__LITBR__Student::Age = 18__LITBR__Student::Name & " is " & StringConstruct ( Student::Age; "a "; " year old" & StringConstruct ( Student::Gender; " "; "."; " person." ); StringConstruct ( Student::Gender; ""; "."; "a person." ) )__LITBR__Returns:__LITBR__"Joe is a 18 year old male."__LITBR____LITBR__Student::Name = "Joe"__LITBR__Student::Gender = ""__LITBR__Student::Age = 18__LITBR__Student::Name & " is " & StringConstruct ( Student::Age; "an "; " year old" & StringConstruct ( Student::Gender; " "; "."; " person." ); StringConstruct ( Student::Gender; ""; "."; "a person." ) )__LITBR__Returns:__LITBR__"Joe is a 18 year old person."__LITBR____LITBR__Student::Name = "Joe"__LITBR__Student::Gender = ""__LITBR__Student::Age = ""__LITBR__Student::Name & " is " & StringConstruct ( Student::Age; "an "; " year old" & StringConstruct ( Student::Gender; " " ; "." ; " person." ) ; StringConstruct ( Student::Gender ; "" ; "." ; "a person." ) )__LITBR__Returns:__LITBR__"Joe is a person."__LITBR____LITBR__Student::Name = "Joe"__LITBR__Student::Gender = "male"__LITBR__Student::Age = 18__LITBR__Student::Name & " is " & StringConstruct ( Student::Age ; "an " ; " year old" & StringConstruct ( Student::Gender ; " " ; "." ; " person." ) ; StringConstruct ( Student::Gender; "" ; "." ; "a person." ) )__LITBR__Returns:__LITBR__"Joe is male."__LITBR____LITBR____LITBR__*/__LITBR____LITBR____LITBR____LITBR__Case ( __LITBR__ not IsEmpty ( text ) ; prefix & text & suffix ; __LITBR__ altText__LITBR__)__LITBR____LITBR__// ===================================__LITBR__/*__LITBR____LITBR__ This function is published on FileMaker Custom Functions__LITBR__ to check for updates and provide feedback and bug reports__LITBR__ please visit http://www.fmfunctions.com/fid/250__LITBR____LITBR__ Prototype: StringConstruct( text; prefix; suffix; altText )__LITBR__ Function Author: Chad S. (http://www.fmfunctions.com/mid/234)__LITBR__ Last updated: 19 February 2010__LITBR__ Version: 1__LITBR____LITBR__*/__LITBR__// ===================================
Login or register to comment
Create a new account with fmcustomfunctions.com or login to post a comment.