Components All New MacOS Windows Linux iOS
Examples Mac & Win Server Client Guides Statistic FMM Blog Deprecated Old

Python.Run

Runs a Python script.

Component Version macOS Windows Linux Server iOS SDK
Python 14.3 ✅ Yes ✅ Yes ✅ Yes ✅ Yes ✅ Yes
MBS( "Python.Run"; PythonRef; ScriptText )   More

Parameters

Parameter Description Example
PythonRef The Python reference number. $python
ScriptText The script text. "print('hello')"

Result

Returns result or error.

Description

Runs a Python script.
Pass the script text to run.
Returns the result of the script.

The script runs within the FileMaker process. If you cause an endless loop, FileMaker freezes and needs to be force quit, so please always include an exit condition for your loops. Also if you get Python to crash, FileMaker will crash with it. Use Shell functions to run Python in a separate process.

Examples

Try it:

Set Variable [ $r ; Value: MBS("Python.Run"; $p; "x = 1¶if x == 1:¶ # indented four spaces¶ print('x is 1.')") ]
Set Variable [ $o ; Value: MBS("Python.PrintOutput"; $p) ]
If [ MBS("IsError") or $o ≠ "x is 1.¶" ]
      Show Custom Dialog [ "Failed to evaluate" ; $r ]
      Exit Script [ Text Result: ]
End If

See also

Release notes

  • Version 14.4
    • Added Python.RunFile function.

Example Databases

Blog Entries

This function checks for a license.

Created 31st May 2024, last changed 8th July 2024


Python.ReleaseAll - Python.RunFile