Components | All | New | MacOS | Windows | Linux | iOS | ||||
Examples | Mac & Win | Server | Client | Guides | Statistic | FMM | Blog | Deprecated | Old |
JS.EvaluateToString
Evaluates a JavaScript expression.
Component | Version | macOS | Windows | Linux | Server | iOS SDK |
JavaScript | 10.0 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |
Parameters
Parameter | Description | Example |
---|---|---|
JSRef | The JavaScript reference number. | $js |
JavaScript | A JavaScript expression. | "1+2" |
Result
Returns text or error.
Description
Evaluates a JavaScript expression.This may include definition of functions and objects and using them.
Result is converted to string and returned.
Examples
Evaluate some text:
Set Variable [ $js ; Value: MBS( "JS.New" ) ]
Set Variable [ $r ; Value: MBS( "JS.EvaluateToString"; $js; "e = \"test\"; e + String.fromCharCode(33)") ]
Show Custom Dialog [ "Result" ; $r ]
Set Variable [ $r ; Value: MBS( "JS.Release"; $JS ) ]
Defines and runs a function in JavaScript:
Let([
f = "
function makeCRCTable(){
var c;
var crcTable = [];
for(var n =0; n < 256; n++){
c = n;
for(var k =0; k < 8; k++){
c = ((c&1) ? (0xEDB88320 ^ (c >>> 1)) : (c >>> 1));
}
crcTable[n] = c;
}
return crcTable;
}
function crc32(str) {
var crcTable = crcTable || (crcTable = makeCRCTable());
var crc = 0 ^ (-1);
for (var i = 0; i < str.length; i++ ) {
crc = (crc >>> 8) ^ crcTable[(crc ^ str.charCodeAt(i)) & 0xFF];
}
return (crc ^ (-1)) >>> 0;
};
crc32(InputValue);";
j = MBS( "JS.New" );
r = MBS( "JS.SetGlobalPropertyValue"; j; "InputValue"; "Hello World" );
r = MBS( "JS.EvaluateToString"; j; f );
x = MBS( "JS.Release"; j )
];r)
See also
- JavaScript.EvaluateScript
- JS.Evaluate
- JS.New
- JS.Release
- JS.SetGlobalProperty
- JS.SetGlobalPropertyValue
Example Databases
- JavaScript/CoordinatDistance
- JavaScript/JavaScript libPhoneNumber
- JavaScript/JavaScript SunCalc
- JavaScript/JavaScript
- JavaScript/RichTextToJSON
Blog Entries
FileMaker Magazin
This function checks for a license.
Created 7th December 2019, last changed 8th July 2021