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

MBS FileMaker Plugin Example Databases

Python

All examples are included with download of MBS FileMaker Plugin.

Python.fmp12

Overview
Tables 1
Relationships 0
Layouts 1
Scripts 6
Value Lists 1
Custom Functions 0
Custom Menus 24
File Options
Default custom menu set [Standard FileMaker Menus]
When opening file
Minimum allowed version 12.0
Login using Account Name; Account= Admin
Allow user to save password On
Require iOS passcode Off
Show Sign-in fields On
Switch to layout Off
Hide all toolbars Off
Script triggers
OnFirstWindowOpen Off
OnLastWindowClose Off
OnWindowOpen Off
OnWindowClose Off
OnFileAVPlayerChange Off
OnWindowTransaction Off
Thumbnail Settings
Generate Thumbnails On; Temporary

 

Tables

Table Name
Statistics
Occurrences in Relationship Graph
Python
11 fields defined, 13 records
Python

Fields

Table Name: Python - 11 Fields
Field Name Type Options Comments On Layouts In Relationships In Scripts In Value Lists
PrimaryKey Normal, Text Auto-Enter:
  • Context table: Python
    Calculation: Get( UUID )
Validation:
  • Only during data entry
  • Not empty
  • Unique
  • Strict validation
Storage:
  • Repetitions: 1
  • Indexing: Minimal
  • Automatically create indexes as needed
  • Index Language: Unicode Raw
Unique identifier of each record in this table
          CreationTimestamp Normal, Timestamp Auto-Enter:
          • Creation timestamp
          Validation:
          • Only during data entry
          • Strict data type: 4 digit year
          • Not empty
          • Strict validation
          Storage:
          • Repetitions: 1
          • Indexing: None
          • Automatically create indexes as needed
          • Index Language: German
          Date and time each record was created
                  CreatedBy Normal, Text Auto-Enter:
                  • Creation account name
                  Validation:
                  • Only during data entry
                  • Not empty
                  • Strict validation
                  Storage:
                  • Repetitions: 1
                  • Indexing: None
                  • Automatically create indexes as needed
                  • Index Language: German
                  Account name of the user who created each record
                          ModificationTimestamp Normal, Timestamp Auto-Enter:
                          • Modification timestamp
                          Validation:
                          • Only during data entry
                          • Strict data type: 4 digit year
                          • Not empty
                          • Strict validation
                          Storage:
                          • Repetitions: 1
                          • Indexing: None
                          • Automatically create indexes as needed
                          • Index Language: German
                          Date and time each record was last modified
                                  ModifiedBy Normal, Text Auto-Enter:
                                  • Modification account name
                                  Validation:
                                  • Only during data entry
                                  • Not empty
                                  • Strict validation
                                  Storage:
                                  • Repetitions: 1
                                  • Indexing: None
                                  • Automatically create indexes as needed
                                  • Index Language: German
                                  Account name of the user who last modified each record
                                          Code Normal, Text Auto-Enter:
                                          • Allow editing
                                          Validation:
                                          • Only during data entry
                                          Storage:
                                          • Repetitions: 1
                                          • Indexing: None
                                          • Automatically create indexes as needed
                                          • Index Language: German
                                              Result Normal, Text Auto-Enter:
                                              • Allow editing
                                              Validation:
                                              • Only during data entry
                                              Storage:
                                              • Repetitions: 1
                                              • Indexing: None
                                              • Automatically create indexes as needed
                                              • Index Language: German
                                                  Print Normal, Text Auto-Enter:
                                                  • Allow editing
                                                  Validation:
                                                  • Only during data entry
                                                  Storage:
                                                  • Repetitions: 1
                                                  • Indexing: None
                                                  • Automatically create indexes as needed
                                                  • Index Language: German
                                                      Description Normal, Text Auto-Enter:
                                                      • Allow editing
                                                      Validation:
                                                      • Only during data entry
                                                      Storage:
                                                      • Repetitions: 1
                                                      • Indexing: None
                                                      • Automatically create indexes as needed
                                                      • Index Language: German
                                                            LibraryVersion Normal, Text Auto-Enter:
                                                            • Allow editing
                                                            Validation:
                                                            • Only during data entry
                                                            Storage:
                                                            • Global
                                                            • Repetitions: 1
                                                            • Index Language: German
                                                                IsEval Normal, Number Auto-Enter:
                                                                • Allow editing
                                                                Validation:
                                                                • Only during data entry
                                                                Storage:
                                                                • Repetitions: 1
                                                                • Indexing: None
                                                                • Automatically create indexes as needed
                                                                • Index Language: German

                                                                      Layout Objects: Python

                                                                      Regular Fields

                                                                      Field Name: Python::Code
                                                                      Field Properties Coordinates Field Format Field Behavior Quick Find
                                                                      • Top: 114 pt
                                                                      • Left: 138 pt
                                                                      • Bottom: 396 pt
                                                                      • Right: 981 pt
                                                                      • Anchoring: Left and Right, Top and Bottom
                                                                      Field Format:
                                                                      • Edit Box
                                                                      Field Behavior:
                                                                      • Allow field to be entered: In Find mode, In Browse mode
                                                                      • Touch keyboard type: Default for Data Type
                                                                      • Go to next field using: Tab key
                                                                      Yes

                                                                      Field Name: Python::Result
                                                                      Field Properties Coordinates Field Format Field Behavior Quick Find
                                                                      • Top: 399 pt
                                                                      • Left: 138 pt
                                                                      • Bottom: 552 pt
                                                                      • Right: 981 pt
                                                                      • Anchoring: Left and Right, Bottom
                                                                      Field Format:
                                                                      • Edit Box
                                                                      Field Behavior:
                                                                      • Allow field to be entered: In Find mode, In Browse mode
                                                                      • Touch keyboard type: Default for Data Type
                                                                      • Go to next field using: Tab key
                                                                      Yes

                                                                      Field Name: Python::Print
                                                                      Field Properties Coordinates Field Format Field Behavior Quick Find
                                                                      • Top: 555 pt
                                                                      • Left: 139 pt
                                                                      • Bottom: 708 pt
                                                                      • Right: 981 pt
                                                                      • Anchoring: Left and Right, Bottom
                                                                      Field Format:
                                                                      • Edit Box
                                                                      Field Behavior:
                                                                      • Allow field to be entered: In Find mode, In Browse mode
                                                                      • Touch keyboard type: Default for Data Type
                                                                      • Go to next field using: Tab key
                                                                      Yes

                                                                      Field Name: Python::Description
                                                                      Field Properties Coordinates Field Format Field Behavior Quick Find
                                                                      • Top: 712 pt
                                                                      • Left: 138 pt
                                                                      • Bottom: 743 pt
                                                                      • Right: 900 pt
                                                                      • Anchoring: Left and Right, Bottom
                                                                      Field Format:
                                                                      • Edit Box
                                                                      Field Behavior:
                                                                      • Allow field to be entered: In Find mode, In Browse mode
                                                                      • Touch keyboard type: Default for Data Type
                                                                      • Go to next field using: Tab key
                                                                      Yes

                                                                      Field Name: Python::LibraryVersion
                                                                      Field Properties Coordinates Field Format Field Behavior Quick Find
                                                                      • Top: 754 pt
                                                                      • Left: 138 pt
                                                                      • Bottom: 785 pt
                                                                      • Right: 980 pt
                                                                      • Anchoring: Left and Right, Bottom
                                                                      Field Format:
                                                                      • Edit Box
                                                                      Field Behavior:
                                                                      • Allow field to be entered: In Find mode, In Browse mode
                                                                      • Touch keyboard type: Default for Data Type
                                                                      • Go to next field using: Tab key
                                                                      No

                                                                      Field Name: Python::IsEval
                                                                      Field Properties Coordinates Field Format Field Behavior Quick Find
                                                                      • Top: 711 pt
                                                                      • Left: 908 pt
                                                                      • Bottom: 742 pt
                                                                      • Right: 981 pt
                                                                      • Anchoring: Right, Bottom
                                                                      Field Format:
                                                                      • Checkbox Set
                                                                      • Display values from: IsEval
                                                                      Field Behavior:
                                                                      • Allow field to be entered: In Find mode, In Browse mode
                                                                      • Touch keyboard type: Default for Data Type
                                                                      • Go to next field using: Tab key
                                                                      Yes

                                                                      Buttons

                                                                      Button Properties Coordinates Script/Script Step
                                                                        Type:
                                                                      • Text: Evaluate
                                                                      • Top: 72 pt
                                                                      • Left: 710 pt
                                                                      • Bottom: 103 pt
                                                                      • Right: 840 pt
                                                                      • Anchoring: Right, Top
                                                                      Perform Script [ “Evaluate Code” ]

                                                                      Scripts:


                                                                      Button Properties Coordinates Script/Script Step
                                                                        Type:
                                                                      • Text: Run Script
                                                                      • Top: 72 pt
                                                                      • Left: 850 pt
                                                                      • Bottom: 103 pt
                                                                      • Right: 980 pt
                                                                      • Anchoring: Right, Top
                                                                      Perform Script [ “Run Script” ]

                                                                      Scripts:


                                                                      Value Lists

                                                                      Value List Name Source Values On Layouts
                                                                      IsEval Custom
                                                                      • IsEval

                                                                      Script Hierarchy

                                                                      Load
                                                                      Tests
                                                                      Show Version
                                                                      Clear Results
                                                                      Evaluate Code
                                                                      Run Script

                                                                      Next Script: [Tests]
                                                                      Script Name Load
                                                                      Run script with full access privileges Off
                                                                      Siri Shortcut Visible Off
                                                                      Include In Menu Yes
                                                                      Layouts that use this script
                                                                        Scripts that use this script
                                                                        Script Definition
                                                                        Script Steps
                                                                        • If [ MBS("IsMacOS") ]
                                                                        • #We installed python via homebrew
                                                                        • Set Variable [ $r; Value:MBS("Python.Load"; "/opt/homebrew/Cellar/python@3.12/3.12.3/Frameworks/Python.framework") ]
                                                                        • Else If [ MBS("IsWindows") ]
                                                                        • #We installed python via the installer from the python website
                                                                        • Set Variable [ $r; Value:MBS("Python.Load"; "C:\Users\cs\AppData\Local\Programs\Python\Python312\python312.dll") ]
                                                                        • Else If [ MBS("IsLinux") ]
                                                                        • #We installed libpython3 packages
                                                                        • Set Variable [ $r; Value:MBS("Python.Load"; "libpython3.11.so") ]
                                                                        • Else
                                                                        • Exit Script [ ]
                                                                        • End If
                                                                        • If [ MBS("IsError") ]
                                                                        • Show Custom Dialog [ Title: "Failed to load library."; Message: $r; Default Button: “OK”, Commit: “Yes” ]
                                                                        • Else
                                                                        • Set Variable [ $p; Value:MBS("Python.LibraryVersion") ]
                                                                        • Set Field [ Python::LibraryVersion; $p ]
                                                                        • End If
                                                                        Fields used in this script
                                                                        Scripts used in this script
                                                                          Layouts used in this script
                                                                            Tables used in this script
                                                                            Table occurrences used by this script
                                                                            Custom Functions used by this script
                                                                              Custom menu set used by this script

                                                                                Previous Script: [Load] Next Script: [Show Version]
                                                                                Script Name Tests
                                                                                Run script with full access privileges Off
                                                                                Siri Shortcut Visible Off
                                                                                Include In Menu Yes
                                                                                Layouts that use this script
                                                                                  Scripts that use this script
                                                                                    Script Definition
                                                                                    Script Steps
                                                                                    • If [ MBS("Python.Loaded") = 0 ]
                                                                                    • Perform Script [ “Load” ]
                                                                                    • End If
                                                                                    • If [ MBS("Python.Loaded") = 1 ]
                                                                                    • Set Variable [ $p; Value:MBS("Python.LibraryVersion") ]
                                                                                    • Set Field [ Python::LibraryVersion; $p ]
                                                                                    • If [ MBS("IsError") ]
                                                                                    • Show Custom Dialog [ Title: "Check version"; Message: $p; Default Button: “OK”, Commit: “Yes” ]
                                                                                    • Exit Script [ ]
                                                                                    • End If
                                                                                    • Set Variable [ $p; Value:MBS("Python.New") ]
                                                                                    • If [ MBS("IsError") ]
                                                                                    • Show Custom Dialog [ Title: "New python"; Message: $p; Default Button: “OK”, Commit: “Yes” ]
                                                                                    • Exit Script [ ]
                                                                                    • End If
                                                                                    • Set Variable [ $r; Value:MBS("Python.SetValue"; $p; "Hello"; "World") ]
                                                                                    • Set Variable [ $r; Value:MBS("Python.GetValue"; $p; "Hello") ]
                                                                                    • If [ MBS("IsError") or $r ≠ "World" ]
                                                                                    • Show Custom Dialog [ Title: "Failed to set and get variable"; Message: $r; Default Button: “OK”, Commit: “Yes” ]
                                                                                    • Exit Script [ ]
                                                                                    • End If
                                                                                    • Set Variable [ $r; Value:MBS("Python.HasValue"; $p; "Hello") ]
                                                                                    • If [ MBS("IsError") or $r ≠ 1 ]
                                                                                    • Show Custom Dialog [ Title: "Failed to check if variable exists"; Message: $r; Default Button: “OK”, Commit: “Yes” ]
                                                                                    • Exit Script [ ]
                                                                                    • End If
                                                                                    • Set Variable [ $r; Value:MBS("Python.HasValue"; $p; "notthere") ]
                                                                                    • If [ MBS("IsError") or $r ≠ 0 ]
                                                                                    • Show Custom Dialog [ Title: "Failed to check if variable exists"; Message: $r; Default Button: “OK”, Commit: “Yes” ]
                                                                                    • Exit Script [ ]
                                                                                    • End If
                                                                                    • Set Variable [ $r; Value:MBS("Python.SetValue"; $p; "Value"; 568) ]
                                                                                    • Set Variable [ $r; Value:MBS("Python.GetValue"; $p; "Value") ]
                                                                                    • If [ MBS("IsError") or $r ≠ 568 ]
                                                                                    • Show Custom Dialog [ Title: "Failed to set and get variable"; Message: $r; Default Button: “OK”, Commit: “Yes” ]
                                                                                    • Exit Script [ ]
                                                                                    • End If
                                                                                    • Set Variable [ $r; Value:MBS("Python.SetValue"; $p; "Value"; 123,456) ]
                                                                                    • Set Variable [ $r; Value:MBS("Python.GetValue"; $p; "Value") ]
                                                                                    • If [ MBS("IsError") or (Round($r; 3) ≠ 123,456) ]
                                                                                    • Show Custom Dialog [ Title: "Failed to set and get variable"; Message: $r; Default Button: “OK”, Commit: “Yes” ]
                                                                                    • Exit Script [ ]
                                                                                    • End If
                                                                                    • Set Variable [ $r; Value:MBS("Python.Keys"; $p) ]
                                                                                    • If [ MBS("IsError") or $r ≠ "input¶Hello¶Value" ]
                                                                                    • Show Custom Dialog [ Title: "Failed to get keys"; Message: $r; Default Button: “OK”, Commit: “Yes” ]
                                                                                    • Exit Script [ ]
                                                                                    • End If
                                                                                    • Set Variable [ $r; Value:MBS("Python.DeleteValue"; $p; "Hello") ]
                                                                                    • If [ MBS("IsError") or $r ≠ "OK" ]
                                                                                    • Show Custom Dialog [ Title: "Failed to delete variable"; Message: $r; Default Button: “OK”, Commit: “Yes” ]
                                                                                    • Exit Script [ ]
                                                                                    • End If
                                                                                    • Set Variable [ $r; Value:MBS("Python.Evaluate"; $p; "1+2") ]
                                                                                    • If [ MBS("IsError") or $r ≠ 3 ]
                                                                                    • Show Custom Dialog [ Title: "Failed to evaluate"; Message: $r; Default Button: “OK”, Commit: “Yes” ]
                                                                                    • Exit Script [ ]
                                                                                    • End If
                                                                                    • Set Variable [ $r; Value:MBS("Python.Evaluate"; $p; "(1,2)") ]
                                                                                    • If [ MBS("IsError") or $r ≠ "(1, 2)" ]
                                                                                    • Show Custom Dialog [ Title: "Failed to evaluate"; Message: $r; Default Button: “OK”, Commit: “Yes” ]
                                                                                    • Exit Script [ ]
                                                                                    • End If
                                                                                    • Set Variable [ $e; Value:MBS("Python.Evaluate"; $p; "print('Hello')") ]
                                                                                    • Set Variable [ $r; Value:MBS("Python.PrintOutput"; $p) ]
                                                                                    • If [ MBS("IsError") or $r ≠ "Hello¶" ]
                                                                                    • Show Custom Dialog [ Title: "Failed to evaluate"; Message: $r; Default Button: “OK”, Commit: “Yes” ]
                                                                                    • Exit Script [ ]
                                                                                    • End If
                                                                                    • Set Variable [ $e; Value:MBS("Python.Evaluate"; $p; "print(1+2)") ]
                                                                                    • Set Variable [ $r; Value:MBS("Python.PrintOutput"; $p) ]
                                                                                    • If [ MBS("IsError") or $r ≠ "3¶" ]
                                                                                    • Show Custom Dialog [ Title: "Failed to evaluate"; Message: $r; Default Button: “OK”, Commit: “Yes” ]
                                                                                    • Exit Script [ ]
                                                                                    • End If
                                                                                    • Set Variable [ $r; Value:MBS("Python.List"; $p) ]
                                                                                    • If [ MBS("IsError") or Position ( $r ; $p ; 1 ; 1 ) = 0 ]
                                                                                    • Show Custom Dialog [ Title: "Failed to list objects"; Message: $r; Default Button: “OK”, Commit: “Yes” ]
                                                                                    • Exit Script [ ]
                                                                                    • End If
                                                                                    • Set Variable [ $r; Value:MBS("Python.AddEvaluateFunction"; $p; "FMEvaluate") ]
                                                                                    • If [ MBS("IsError") or $r ≠ "OK" ]
                                                                                    • Show Custom Dialog [ Title: "Failed to evaluate"; Message: $r; Default Button: “OK”, Commit: “Yes” ]
                                                                                    • Exit Script [ ]
                                                                                    • End If
                                                                                    • Set Variable [ $r; Value:MBS("Python.Evaluate"; $p; "FMEvaluate('1+2')") ]
                                                                                    • If [ MBS("IsError") or $r ≠ "3" ]
                                                                                    • Show Custom Dialog [ Title: "Failed to evaluate"; Message: $r; Default Button: “OK”, Commit: “Yes” ]
                                                                                    • Exit Script [ ]
                                                                                    • End If
                                                                                    • Set Variable [ $r; Value:MBS("Python.AddExecuteSQLFunction"; $p; "FMExecuteSQL") ]
                                                                                    • If [ MBS("IsError") or $r ≠ "OK" ]
                                                                                    • Show Custom Dialog [ Title: "Failed to evaluate"; Message: $r; Default Button: “OK”, Commit: “Yes” ]
                                                                                    • Exit Script [ ]
                                                                                    • End If
                                                                                    • Set Variable [ $r; Value:MBS("Python.Evaluate"; $p; "FMExecuteSQL('SELECT 1+2 FROM Python')") ]
                                                                                    • If [ MBS("IsError") or Left($r; 3) ≠ "[[3" ]
                                                                                    • Show Custom Dialog [ Title: "Failed to evaluate"; Message: $r; Default Button: “OK”, Commit: “Yes” ]
                                                                                    • Exit Script [ ]
                                                                                    • End If
                                                                                    • 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 [ Title: "Failed to evaluate"; Message: $r; Default Button: “OK”, Commit: “Yes” ]
                                                                                    • Exit Script [ ]
                                                                                    • End If
                                                                                    • Set Variable [ $r; Value:MBS("Python.Release"; $p) ]
                                                                                    • If [ MBS("IsError") or $r ≠ "OK" ]
                                                                                    • Show Custom Dialog [ Title: "Failed release"; Message: $r; Default Button: “OK”, Commit: “Yes” ]
                                                                                    • Exit Script [ ]
                                                                                    • End If
                                                                                    • Show Custom Dialog [ Title: "Tests success"; Message: "all okay."; Default Button: “OK”, Commit: “Yes” ]
                                                                                    • End If
                                                                                    Fields used in this script
                                                                                    Scripts used in this script
                                                                                    Layouts used in this script
                                                                                      Tables used in this script
                                                                                      Table occurrences used by this script
                                                                                      Custom Functions used by this script
                                                                                        Custom menu set used by this script

                                                                                          Previous Script: [Tests] Next Script: [Clear Results]
                                                                                          Script Name Show Version
                                                                                          Run script with full access privileges Off
                                                                                          Siri Shortcut Visible Off
                                                                                          Include In Menu Yes
                                                                                          Layouts that use this script
                                                                                            Scripts that use this script
                                                                                              Script Definition
                                                                                              Script Steps
                                                                                              • Show Custom Dialog [ Title: "Python Version"; Message: MBS( "Python.LibraryVersion" ); Default Button: “OK”, Commit: “Yes” ]
                                                                                              Fields used in this script
                                                                                                Scripts used in this script
                                                                                                  Layouts used in this script
                                                                                                    Tables used in this script
                                                                                                      Table occurrences used by this script
                                                                                                        Custom Functions used by this script
                                                                                                          Custom menu set used by this script

                                                                                                            Previous Script: [Show Version] Next Script: [Evaluate Code]
                                                                                                            Script Name Clear Results
                                                                                                            Run script with full access privileges Off
                                                                                                            Siri Shortcut Visible Off
                                                                                                            Include In Menu Yes
                                                                                                            Layouts that use this script
                                                                                                              Scripts that use this script
                                                                                                                Script Definition
                                                                                                                Script Steps
                                                                                                                • Replace Field Contents [ Python::Print; Replace with calculation: "" ] [ No dialog ]
                                                                                                                • Replace Field Contents [ Python::Result; Replace with calculation: "" ] [ No dialog ]
                                                                                                                • Replace Field Contents [ Python::LibraryVersion; Replace with calculation: "" ] [ No dialog ]
                                                                                                                Fields used in this script
                                                                                                                Scripts used in this script
                                                                                                                  Layouts used in this script
                                                                                                                    Tables used in this script
                                                                                                                    Table occurrences used by this script
                                                                                                                    Custom Functions used by this script
                                                                                                                      Custom menu set used by this script

                                                                                                                        Previous Script: [Clear Results] Next Script: [Run Script]
                                                                                                                        Script Name Evaluate Code
                                                                                                                        Run script with full access privileges Off
                                                                                                                        Siri Shortcut Visible Off
                                                                                                                        Include In Menu Yes
                                                                                                                        Layouts that use this script
                                                                                                                        Scripts that use this script
                                                                                                                          Script Definition
                                                                                                                          Script Steps
                                                                                                                          Fields used in this script
                                                                                                                          Scripts used in this script
                                                                                                                          Layouts used in this script
                                                                                                                            Tables used in this script
                                                                                                                            Table occurrences used by this script
                                                                                                                            Custom Functions used by this script
                                                                                                                              Custom menu set used by this script

                                                                                                                                Previous Script: [Evaluate Code]
                                                                                                                                Script Name Run Script
                                                                                                                                Run script with full access privileges Off
                                                                                                                                Siri Shortcut Visible Off
                                                                                                                                Include In Menu Yes
                                                                                                                                Layouts that use this script
                                                                                                                                Scripts that use this script
                                                                                                                                  Script Definition
                                                                                                                                  Script Steps
                                                                                                                                  Fields used in this script
                                                                                                                                  Scripts used in this script
                                                                                                                                  Layouts used in this script
                                                                                                                                    Tables used in this script
                                                                                                                                    Table occurrences used by this script
                                                                                                                                    Custom Functions used by this script
                                                                                                                                      Custom menu set used by this script

                                                                                                                                        Download example: Python

                                                                                                                                        Used functions: