Variable.Set
------------

Stores a named variable that can be retrieved later using [Variable.Get](VariableGet.md).

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [Variable](component_Variable.md) | [1.2](newinversion12.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "Variable.Set"; Name; Value ) 

**MBS**( **"Variable.Set";** /\* Stores a named variable that can be retrieved later using Variable.Get. \*/  
**$Name**; /\* the name of the variable \*/   
**$Value**) /\* the value to assign to the variable \*/ 

(old name: FM.VariableSet)

### Parameters

| Parameter | Description | Example |
|---|---|---|
| Name | the name of the variable |  |
| Value | the value to assign to the variable |  |

### Description

Stores a named variable that can be retrieved later using [Variable.Get](VariableGet.md).  
Unlike the variables that were introduced in FileMaker 8 these variables are not limited to the File or Script. In other words they can be retrieved from any file in the system regardless of where they were declared. All values are stored in their native data types (up to version 4.4 only text).  
  
Use [Variable.Clear](VariableClear.md) to clear the variables or [Variable.ClearAll](VariableClearAll.md) to clear them all. [Variable.List](VariableList.md) returns list of all defined variables.  
  
On server, variables are shared by all users connected to the same server and will persist between sessions. So, for example, all Web Direct users will have the same set of global variables set via the plugin. You can optionally prefix variables with a user ID/Name to make them per-user unique. Variables will stay in memory until explicitly released; or the process quits. If you'd like to share data between multiple processes (e.g. Web Direct, Data API and Server Scripting), please use the [SharedMemory](component_SharedMemory.md) functions like [SharedMemory.SetValue](SharedMemorySetValue.md).  
### Examples

Set a variable

 MBS ( "Variable.Set" ; "myVar"; "Hello" )  
### See also

- [SharedMemory.SetValue](SharedMemorySetValue.md)
- [Variable.Append](VariableAppend.md)
- [Variable.Clear](VariableClear.md)
- [Variable.ClearAll](VariableClearAll.md)
- [Variable.Exists](VariableExists.md)
- [Variable.Get](VariableGet.md)
- [Variable.List](VariableList.md)
- [Variable.Names](VariableNames.md)
- [Variable.Reset](VariableReset.md)
- [Variable.ValueCount](VariableValueCount.md)

### Example Databases

- [CURL/WebViewer Download Images with CURL](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/CURL/WebViewer%20Download%20Images%20with%20CURL.shtml#1ScriptAnchor_)
- [Drag and Drop/for Mac/Image drag from one database to other/Image drag](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Drag%20and%20Drop/for%20Mac/Image%20drag%20from%20one%20database%20to%20other/Image%20drag.shtml#6ScriptAnchor_)
- [Drag and Drop/for Mac/Text drag from one database to other/Text drag](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Drag%20and%20Drop/for%20Mac/Text%20drag%20from%20one%20database%20to%20other/Text%20drag.shtml#6ScriptAnchor_)
- [SmartCard/Belgian EID Reader](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/SmartCard/Belgian%20EID%20Reader.shtml#7ScriptAnchor_)
- [Third Party/FileMaker Snippet Storage](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Third%20Party/FileMaker%20Snippet%20Storage.shtml#60CustomFunctionAnchor_)
- [Utility functions/Global Variables](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Utility%20functions/Global%20Variables.shtml#1ScriptAnchor_)
- [Window/Window Activation Trigger](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Window/Window%20Activation%20Trigger.shtml#2ScriptAnchor_)

### Blog Entries

- [Additional variable levels in FileMaker with MBS Plugin](https://www.mbsplugins.de/archive/2024-06-08/Additional_variable_levels_in_/monkeybreadsoftware_blog_filemaker)
- [Window Activation Trigger](https://www.mbsplugins.de/archive/2022-10-23/Window_Activation_Trigger/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin 12.3](https://www.mbsplugins.de/archive/2022-07-19/MBS_FileMaker_Plugin_123/monkeybreadsoftware_blog_filemaker)
- [New functions of the MBS Plugin Version 9.5](https://www.mbsplugins.de/archive/2019-11-21/New_functions_of_the_MBS_Plugi/monkeybreadsoftware_blog_filemaker)
- [Data structures in FileMaker with MBS Plugins](https://www.mbsplugins.de/archive/2017-10-19/Data_structures_in_FileMaker_w/monkeybreadsoftware_blog_filemaker)
- [The power of global variables](https://www.mbsplugins.de/archive/2016-06-09/The_power_of_global_variables/monkeybreadsoftware_blog_filemaker)

### FileMaker Magazin

- [Ausgabe 6/2019, Seite 33](https://filemaker-magazin.de/neuigkeit/4064-Appetithappen-FMM_201906)
- [Ausgabe 2/2014, Seite 31](https://filemaker-magazin.de/neuigkeit/3731-Appetithappen-FMM_201402)

This function checks for a license.

Created 18th August 2014 , last changed 16th April 2025

  
[Variable.Reset](VariableReset.md) - [Variable.ValueCount](VariableValueCount.md)

[HTML Version](VariableSet.shtml)