Text.WriteToContainer
---------------------

Write a text as a FILE in a container.

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

MBS( "Text.WriteToContainer"; Text { ; Encoding; FilePath } ) 

**MBS**( **"Text.WriteToContainer";** /\* Write a text as a FILE in a container. \*/  
**$Text**; /\* The text to save.e.g. "Hello World" \*/   
**$Encoding**; /\* Optional; The text encoding for text parameter.   
Default is native.e.g. "UTF-8" \*/   
**$FilePath**) /\* Optional; The file name to include in the container value.e.g. "test.txt" \*/ 

(old name: String.WriteToContainer)

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| Text | The text to save. | "Hello World" |  |
| Encoding | The text encoding for text parameter.    Default is native.   Possible encoding names: ANSI, ISO-8859-1, Latin1, Mac, Native, UTF-8, DOS, Hex, Base64 or Windows. More listed in the [FAQ](https://www.monkeybreadsoftware.com/filemaker/faq.shtml). | "UTF-8" | Optional |
| FilePath | The file name to include in the container value. | "test.txt" | Optional |

### Result

Returns OK or error.

### Description

Write a text as a FILE in a container.  
The result can be assigned to a container field and later be exported.  
  
This function works on pure text, so any text style is lost.  
### Examples

Writes some text to container:

 Set Field \[ MyTable::Test ; Value: MBS ("Text.WriteToContainer"; "Hello World"; "UTF-8"; "test.txt") \]  
### See also

- [BinaryFile.WriteText](BinaryFileWriteText.md)
- [FM.DataType](FMDataType.md)
- [RichText.WriteContainer](RichTextWriteContainer.md)

### Release notes

- **Version 12.2**
    - Changed [Text.AppendTextFile](https://www.mbsplugins.eu/TextAppendTextFile.shtml), [Text.WriteToContainer](https://www.mbsplugins.eu/TextWriteToContainer.shtml) and [Text.WriteTextFile](https://www.mbsplugins.eu/TextWriteTextFile.shtml) to allow writing BOM character.

### Blog Entries

- [Store large texts as container fields](https://www.mbsplugins.de/archive/2024-06-13/Store_large_texts_as_container/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 12.2pr1](https://www.mbsplugins.de/archive/2022-04-01/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [MBS Filemaker Plugin, version 4.4pr6](https://www.mbsplugins.de/archive/2014-10-20/MBS_Filemaker_Plugin_version_4/monkeybreadsoftware_blog_filemaker)

This function is free to use.

Created 18th October 2014 , last changed 4th August 2023

  
[Text.WriteTextFile](TextWriteTextFile.md) - [Text.ZLibCompress](TextZLibCompress.md)

[HTML Version](TextWriteToContainer.shtml)