BinaryFile.WriteText
--------------------

Writes a text file with the given text.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [BinaryFile](component_BinaryFile.md) | [7.3](newinversion73.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "BinaryFile.WriteText"; BinaryFileRef; Text { ; Encoding } ) 

**MBS**( **"BinaryFile.WriteText";** /\* Writes a text file with the given text. \*/  
**$BinaryFileRef**; /\* The reference number for the open file.e.g. $FH \*/   
**$Text**; /\* The text to write.e.g. "Hello World" \*/   
**$Encoding**) /\* Optional; The text encoding for text parameter.   
Default is UTF-8.e.g. "UTF-8" \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| BinaryFileRef | The reference number for the open file. | $FH |  |
| Text | The text to write. | "Hello World" |  |
| Encoding | The text encoding for text parameter.    Default is UTF-8.   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 |

### Result

Returns OK or error.

### Description

Writes a text file with the given text.  
You have to decide which encoding to use (if not UTF-8). We support a few encodings, but we can add more if you need something special.  
Please use [Text.ReplaceNewLine](TextReplaceNewLine.md) to define which line endings the file has.  
If text encoding doesn't support given characters, they are converted to close match if possible or replaced by question marks.  
  
You can pass UTF-16, UTF-16LE or UTF-16BE for encoding, too.   
  
See also [Text.WriteTextFile](TextWriteTextFile.md) and [Text.WriteToContainer](TextWriteToContainer.md).  
### Examples

Write Hello:

 MBS ( "BinaryFile.WriteText"; $fh ; "Hello"; "UTF8")  
### See also

- [BinaryFile.Close](BinaryFileClose.md)
- [BinaryFile.Create](BinaryFileCreate.md)
- [BinaryFile.ReadText](BinaryFileReadText.md)
- [BinaryFile.WriteByte](BinaryFileWriteByte.md)
- [BinaryFile.WriteContainer](BinaryFileWriteContainer.md)
- [BinaryFile.WriteFloat](BinaryFileWriteFloat.md)
- [BinaryFile.WriteInt](BinaryFileWriteInt.md)
- [Text.ReplaceNewLine](TextReplaceNewLine.md)
- [Text.WriteTextFile](TextWriteTextFile.md)
- [ZipFile.WriteText](ZipFileWriteText.md)

### Blog Entries

- [MBS FileMaker Advent calendar - Door 18 - ics-Files](https://www.mbsplugins.de/archive/2024-12-18/MBS_FileMaker_Advent_calendar_/monkeybreadsoftware_blog_filemaker)
- [MBS Plugin Advent calendar: 3 - BinaryFile](https://www.mbsplugins.de/archive/2023-12-03/MBS_Plugin_Advent_calendar_3_-/monkeybreadsoftware_blog_filemaker)
- [FileMaker 18 File Script Steps vs. BinaryFile functions](https://www.mbsplugins.de/archive/2019-06-03/FileMaker_18_File_Script_Steps/monkeybreadsoftware_blog_filemaker)

### FileMaker Magazin

- [Ausgabe 2/2025, Seite 24](https://filemaker-magazin.de/neuigkeit/4286-Appetithappen-FMM_202502)
- [Ausgabe 5/2024, Seite 29](https://filemaker-magazin.de/neuigkeit/4272-Appetithappen-FMM_202405)

This function checks for a license.

Created 12nd June 2017 , last changed 12nd June 2017

  
[BinaryFile.WriteInt](BinaryFileWriteInt.md) - [BlueThermProbe.ConnectToDevice](BlueThermProbeConnectToDevice.md)

[HTML Version](BinaryFileWriteText.shtml)