Text.MergeFields
----------------

Merge field and variable names into text.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [Text](component_Text.md) | [8.5](newinversion85.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "Text.MergeFields"; Text; Flags ) 

**MBS**( **"Text.MergeFields";** /\* Merge field and variable names into text. \*/  
**$Text**; /\* The input text.e.g. "Hello &lt;&lt;$name&gt;&gt;" \*/   
**$Flags**) /\* The various flags.  
1 to allow field names.  
2 to allow variables.  
4 to allow expressions to evaluate.  
16 to output XML  
32 to output HTML.e.g. 1+2+4+32 \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| Text | The input text. | "Hello &lt;&lt;$name&gt;&gt;" |
| Flags | The various flags.   1 to allow field names.   2 to allow variables.   4 to allow expressions to evaluate.   16 to output XML   32 to output HTML. | 1+2+4+32 |

### Result

Returns OK or error.

### Description

Merge field and variable names into text.  
This functions look for items between &lt;&lt; and &gt;&gt; to replace those with real values from fields, variables or expressions. This function does not preserve formatting.  
For use in XML or HTML, we can encode all replacement values for you.  
  
If you allow expressions, that may include plugins calls, so user could do anything via MBS calls!  
### Examples

Use function with Variable:

 Set Variable \[ $FirstName ; Value: "Christian" \]   
Set Variable \[ $text ; Value: "Hello &lt;&lt;$FirstName &gt;&gt;" \]   
Set Variable \[ $text ; Value: MBS ( "Text.MergeFields"; $text ; 1+2 ) \]   
Show Custom Dialog \[ $text \]  
### See also

- [SendMail.SetHTMLText](SendMailSetHTMLText.md)
- [SendMail.SetPlainText](SendMailSetPlainText.md)
- [WinSendMail.SetText](WinSendMailSetText.md)

### Release notes

- **Version 9.0**
    - Fixed problem with [Text.MergeFields](http://www.mbsplugins.eu/TextMergeFields.shtml) not finding variable always.
- **Version 8.5**
    - Added [Text.MergeFields](http://www.mbsplugins.eu/TextMergeFields.shtml) function.

### Example Databases

- [Text functions/Merge Fields](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Text%20functions/Merge%20Fields.shtml#1ScriptAnchor_)

### Blog Entries

- [Combined Components with MBS FileMaker Plugin](https://www.mbsplugins.de/archive/2021-03-29/Combined_Components_with_MBS_F/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 8.6pr5](https://www.mbsplugins.de/archive/2018-12-23/MBS_FileMaker_Plugin_version_8/monkeybreadsoftware_blog_filemaker)
- [Neues MBS FileMaker Plugin 8.5 - Über 5500 Funktionen in einem Plugin](https://www.mbsplugins.de/archive/2018-11-27/Neues_MBS_FileMaker_Plugin_85_/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin 8.5 - More than 5500 Functions In One Plugin](https://www.mbsplugins.de/archive/2018-11-27/MBS_FileMaker_Plugin_85_-_More/monkeybreadsoftware_blog_filemaker)
- [Merge field values into text](https://www.mbsplugins.de/archive/2018-10-24/Merge_field_values_into_text/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 8.5pr3](https://www.mbsplugins.de/archive/2018-10-24/MBS_FileMaker_Plugin_version_8/monkeybreadsoftware_blog_filemaker)

### FileMaker Magazin

- [Ausgabe 6/2018, Seite 33](https://filemaker-magazin.de/neuigkeit/4025-Appetithappen-FMM_201806)

This function checks for a license.

Created 14th October 2018 , last changed 6th December 2019

  
[Text.LowerCase](TextLowerCase.md) - [Text.MimeTypeToFileExtension](TextMimeTypeToFileExtension.md)

[HTML Version](TextMergeFields.shtml)