JavaScript.RegisterRunScriptFunction
------------------------------------

Registers a run script function.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [JavaScriptWebKit](component_JavaScriptWebKit.md) | [5.4](newinversion54.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "JavaScript.RegisterRunScriptFunction"; JavaScriptContext; FunctionName ) 

**MBS**( **"JavaScript.RegisterRunScriptFunction";** /\* Registers a run script function. \*/  
**$JavaScriptContext**; /\* The reference number of the javascript context.e.g. $Context \*/   
**$FunctionName**) /\* The name for the new function.e.g. "StartScript" \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| JavaScriptContext | The reference number of the javascript context. | $Context |
| FunctionName | The name for the new function. | "StartScript" |

### Result

Returns OK or error.

### Description

Registers a run script function.  
The javascript function takes first parameter the filename, second parameter the script name. Optionally third parameter is passed as text to the script.  
Call for example like this: FMRunScript('Javascript.fp7', 'test', 'Hello World')  
### Examples

Register RunScript function:

 Set Variable \[$r ; Value:MBS ( "JavaScript.RegisterRunScriptFunction"; $$Context ; "FMRunScript" )\]  
\# later:   
\# FMRunScript('Javascript.fp7', 'test', 'Hello World')   
### See also

- [JavaScript.CF](JavaScriptCF.md)
- [JavaScript.RegisterEvaluateFunction](JavaScriptRegisterEvaluateFunction.md)
- [JavaScript.RegisterSQLQueryFunction](JavaScriptRegisterSQLQueryFunction.md)

### Example Databases

- [JavaScript WebKit/JavaScript](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/JavaScript%20WebKit/JavaScript.shtml#1ScriptAnchor_)

### Blog Entries

- [Custom Functions in JavaScript reloaded](https://www.mbsplugins.de/archive/2022-05-05/Custom_Functions_in_JavaScript/monkeybreadsoftware_blog_filemaker)

This function checks for a license.

Created 7th November 2015 , last changed 9th February 2023

  
[JavaScript.RegisterFunction](JavaScriptRegisterFunction.md) - [JavaScript.RegisterSQLQueryFunction](JavaScriptRegisterSQLQueryFunction.md)

[HTML Version](JavaScriptRegisterRunScriptFunction.shtml)