Archive.AddText
---------------

Add a text file to the archive.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [Archive](component_Archive.md) | [13.1](newinversion131.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "Archive.AddText"; Text; Encoding; FileName { ; TimeStamp } ) 

**MBS**( **"Archive.AddText";** /\* Add a text file to the archive. \*/  
**$Text**; /\* The text to save.e.g. "Hello World" \*/   
**$Encoding**; /\* The text encoding for text parameter.   
Default is native.e.g. "UTF-8" \*/   
**$FileName**; /\* The file name to use.  
May contain relative path parts.e.g. "Documents/test.txt" \*/   
**$TimeStamp**) /\* Optional; The timestamp to use in the archive for the file.  
Can be empty to use today.e.g. "" \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| Text | The text to save. | "Hello World" |  |
| Encoding | The text encoding for text parameter.    Default is native. | "UTF-8" |  |
| FileName | The file name to use.   May contain relative path parts. | "Documents/test.txt" |  |
| TimeStamp | The timestamp to use in the archive for the file.   Can be empty to use today. | "" | Optional      Added in version **14.0**. |

### Result

Returns OK or error.

### Description

Add a text file to the archive.  
Please use [Archive.Create](ArchiveCreate.md) before adding the first file and use [Archive.Close](ArchiveClose.md) after the last file to finish.  
  
The plugin does not check for duplicate file names in the archive.  
### Examples

Compress PDF containers into a zip file with a readme file:

 Set Variable \[ $path ; Value: MBS ( "[Path.AddPathComponent](PathAddPathComponent.md)"; MBS ( "[Folders.UserDesktop](FoldersUserDesktop.md)" ); "test.zip" ) \]   
Set Variable \[ $r ; Value: MBS ( "[Archive.Create](ArchiveCreate.md)"; "zip"; "deflate"; $path ) \]   
If \[ MBS ("IsError") \]   
 Show Custom Dialog \[ "Failed to create zip archive." ; $r \]   
 Exit Script \[ Text Result: \]   
End If  
\#   
Set Variable \[ $r ; Value: MBS ( "Archive.AddText"; "PDF documents related to order " &amp; Orders::ID ; "UTF-8"; "ReadMe.txt" ) \]   
Go to Record/Request/Page \[ First \]  
Set Variable \[ $destPage ; Value: 1 \]   
Loop  
 Set Variable \[ $r ; Value: MBS ( "[Archive.AddContainer](ArchiveAddContainer.md)"; Orders::PDF ) \]   
 Go to Record/Request/Page \[ Next ; Exit after last: On \]  
End Loop  
Set Variable \[ $r ; Value: MBS ( "[Archive.Close](ArchiveClose.md)") \]  
### See also

- [Archive.AddContainer](ArchiveAddContainer.md)
- [Archive.AddFile](ArchiveAddFile.md)
- [Archive.Close](ArchiveClose.md)
- [Archive.Create](ArchiveCreate.md)
- [Folders.UserDesktop](FoldersUserDesktop.md)
- [IsError](IsError.md)
- [Path.AddPathComponent](PathAddPathComponent.md)

### Release notes

- **Version 14.3**
    - Fixed [Archive.AddText](https://www.mbsplugins.eu/ArchiveAddText.shtml) function to allow relative paths in file name parameter.
- **Version 14.0**
    - Added new parameter for [Archive.AddContainer](https://www.mbsplugins.eu/ArchiveAddContainer.shtml), [Archive.AddFile](https://www.mbsplugins.eu/ArchiveAddFile.shtml) and [Archive.AddText](https://www.mbsplugins.eu/ArchiveAddText.shtml) to pass a timestamp to use.
- **Version 13.1**
    - Added [Archive.Create](https://www.mbsplugins.eu/ArchiveCreate.shtml), [Archive.AddContainer](https://www.mbsplugins.eu/ArchiveAddContainer.shtml), [Archive.AddFile](https://www.mbsplugins.eu/ArchiveAddFile.shtml), [Archive.AddText](https://www.mbsplugins.eu/ArchiveAddText.shtml) and [Archive.Close](https://www.mbsplugins.eu/ArchiveClose.shtml) functions.

### Example Databases

- [Archives/Archives](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Archives/Archives.shtml#2ScriptAnchor_)

### Blog Entries

- [MBS FileMaker Advent calendar - Door 9 - Archives](https://www.mbsplugins.de/archive/2024-12-09/MBS_FileMaker_Advent_calendar_/monkeybreadsoftware_blog_filemaker)
- [Compress and Send](https://www.mbsplugins.de/archive/2024-07-06/Compress_and_Send/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 14.3pr5](https://www.mbsplugins.de/archive/2024-06-26/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [Neues MBS Plugin 14.0 für Claris FileMaker](https://www.mbsplugins.de/archive/2024-01-16/Neues_MBS_Plugin_140_für_Clar/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin 14.0 for Claris FileMaker](https://www.mbsplugins.de/archive/2024-01-16/MBS_FileMaker_Plugin_140_for_C/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 14.0pr7](https://www.mbsplugins.de/archive/2024-01-08/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [New in MBS FileMaker Plugin 13.1](https://www.mbsplugins.de/archive/2023-03-15/New_in_MBS_FileMaker_Plugin_13/monkeybreadsoftware_blog_filemaker)
- [Build archives on the fly](https://www.mbsplugins.de/archive/2023-02-27/Build_archives_on_the_fly/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 13.1pr3](https://www.mbsplugins.de/archive/2023-02-16/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)

### FileMaker Magazin

- [Ausgabe 4/2023, Seite 37 bis 38](https://filemaker-magazin.de/neuigkeit/4233-Appetithappen-FMM_202304)

This function checks for a license.

Created 13th February 2023 , last changed 25th January 2025

  
[Archive.AddFile](ArchiveAddFile.md) - [Archive.BZip2Version](ArchiveBZip2Version.md)

[HTML Version](ArchiveAddText.shtml)