JavaScript.RegisterEvaluateFunction
-----------------------------------

Registers evaluate function.

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

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

**MBS**( **"JavaScript.RegisterEvaluateFunction";** /\* Registers evaluate function. \*/  
**$JavaScriptContext**; /\* The reference number of the javascript context.e.g. $Context \*/   
**$FunctionName**) /\* The name for the new function.e.g. "Evaluate" \*/ 

### Parameters

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

### Result

Returns OK or error.

### Description

Registers evaluate function.  
The javascript function takes one parameter which is expression to evaluate. Returns the text of the expression result.  
Call later like this: FMEvaluate("Get(AccountName)")  
### Examples

Register function:

 MBS ( "JavaScript.RegisterEvaluateFunction"; $$Context ; "FMEvaluate" )  
\# later:   
\# FMEvaluate("Get(AccountName)")   
Evaluate in javascript the FileMaker get function:

 Set Variable \[ $js ; Value: MBS ( "[JavaScript.New](JavaScriptNew.md)" ) \]   
Set Variable \[ $r ; Value: MBS ( "JavaScript.RegisterEvaluateFunction"; $js ; "FMEvaluate" ) \]   
Set Variable \[ $r ; Value: MBS ( "[JavaScript.EvaluateScript](JavaScriptEvaluateScript.md)"; $js ; "FMEvaluate('Get(AccountName)') + ' from javascript'") \]   
Show Custom Dialog \[ "Result" ; $r \]   
Set Variable \[ $r ; Value: MBS ( "[JavaScript.Release](JavaScriptRelease.md)"; $js ) \]  
### See also

- [JavaScript.CF](JavaScriptCF.md)
- [JavaScript.EvaluateScript](JavaScriptEvaluateScript.md)
- [JavaScript.New](JavaScriptNew.md)
- [JavaScript.RegisterFunction](JavaScriptRegisterFunction.md)
- [JavaScript.RegisterRunScriptFunction](JavaScriptRegisterRunScriptFunction.md)
- [JavaScript.RegisterSQLQueryFunction](JavaScriptRegisterSQLQueryFunction.md)
- [JavaScript.Release](JavaScriptRelease.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.New](JavaScriptNew.md) - [JavaScript.RegisterFunction](JavaScriptRegisterFunction.md)

[HTML Version](JavaScriptRegisterEvaluateFunction.shtml)