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

MBS FileMaker Plugin Example Databases

SQLite fun

All examples are included with download of MBS FileMaker Plugin.

SQLite fun.fmp12

Overview
Tables1
Relationships0
Layouts1
Scripts8
Value Lists0
Custom Functions0
Custom Menus33
File Options
Default custom menu set[Standard FileMaker Menus]
When opening file
Minimum allowed version12.0
Login usingAccount Name; Account= Admin
Allow user to save passwordOff
Require iOS passcodeOff
Switch to layoutOff
Hide all toolbarsOff
Script triggers
OnFirstWindowOpenOff
OnLastWindowCloseOff
OnWindowOpenOff
OnWindowCloseOff
OnFileAVPlayerChangeOff
Thumbnail Settings
Generate ThumbnailsOn; Temporary

 

Tables

Table Name
Statistics
Occurrences in Relationship Graph
SQLite fun
7 fields defined, 1 record
SQLite fun

Fields

Table Name: SQLite fun - 7 Fields
Field NameTypeOptionsCommentsOn LayoutsIn RelationshipsIn ScriptsIn Value Lists
FirstNameNormal, TextAuto-Enter:
  • Allow editing
Validation:
  • Only during data entry
Storage:
  • Repetitions: 1
  • Indexing: None
  • Automatically create indexes as needed
  • Index Language: German
      LastNameNormal, TextAuto-Enter:
      • Allow editing
      Validation:
      • Only during data entry
      Storage:
      • Repetitions: 1
      • Indexing: None
      • Automatically create indexes as needed
      • Index Language: German
          BirthdayNormal, DateAuto-Enter:
          • Allow editing
          Validation:
          • Only during data entry
          Storage:
          • Repetitions: 1
          • Indexing: None
          • Automatically create indexes as needed
          • Index Language: German
              NumberOfOrdersNormal, NumberAuto-Enter:
              • Allow editing
              Validation:
              • Only during data entry
              Storage:
              • Repetitions: 1
              • Indexing: None
              • Automatically create indexes as needed
              • Index Language: German
                  TotalSalesNormal, NumberAuto-Enter:
                  • Allow editing
                  Validation:
                  • Only during data entry
                  Storage:
                  • Repetitions: 1
                  • Indexing: None
                  • Automatically create indexes as needed
                  • Index Language: German
                      PathToSQLiteLibraryNormal, TextAuto-Enter:
                      • Allow editing
                      Validation:
                      • Only during data entry
                      Storage:
                      • Global
                      • Repetitions: 1
                      • Index Language: German
                          PathToSQLiteDatabaseNormal, TextAuto-Enter:
                          • Allow editing
                          Validation:
                          • Only during data entry
                          Storage:
                          • Global
                          • Repetitions: 1
                          • Index Language: German

                              Layout Objects: SQLite fun

                              Regular Fields

                              Field Name: SQLite fun::PathToSQLiteLibrary
                              Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                              • Top: 63 pt
                              • Left: 138 pt
                              • Bottom: 82 pt
                              • Right: 391 pt
                              • Anchoring: Left, Top
                              Field Format:
                              • Edit Box
                              Field Behavior:
                              • Allow field to be entered: In Find mode, In Browse mode
                              • Touch keyboard type: System Default
                              • Go to next field using: Tab key
                              No

                              Field Name: SQLite fun::PathToSQLiteDatabase
                              Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                              • Top: 84 pt
                              • Left: 138 pt
                              • Bottom: 103 pt
                              • Right: 391 pt
                              • Anchoring: Left, Top
                              Field Format:
                              • Edit Box
                              Field Behavior:
                              • Allow field to be entered: In Find mode, In Browse mode
                              • Touch keyboard type: System Default
                              • Go to next field using: Tab key
                              No

                              Field Name: SQLite fun::FirstName
                              Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                              • Top: 114 pt
                              • Left: 138 pt
                              • Bottom: 133 pt
                              • Right: 391 pt
                              • Anchoring: Left, Top
                              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: SQLite fun::LastName
                              Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                              • Top: 137 pt
                              • Left: 138 pt
                              • Bottom: 156 pt
                              • Right: 391 pt
                              • Anchoring: Left, Top
                              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: SQLite fun::Birthday
                              Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                              • Top: 160 pt
                              • Left: 138 pt
                              • Bottom: 179 pt
                              • Right: 391 pt
                              • Anchoring: Left, Top
                              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: SQLite fun::NumberOfOrders
                              Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                              • Top: 183 pt
                              • Left: 138 pt
                              • Bottom: 202 pt
                              • Right: 391 pt
                              • Anchoring: Left, Top
                              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: SQLite fun::TotalSales
                              Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                              • Top: 206 pt
                              • Left: 138 pt
                              • Bottom: 225 pt
                              • Right: 391 pt
                              • Anchoring: Left, Top
                              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

                              Buttons

                              Button PropertiesCoordinatesScript/Script Step
                                Type:
                              • Text: Create SQLite Database
                              • Top: 12 pt
                              • Left: 9 pt
                              • Bottom: 38 pt
                              • Right: 159 pt
                              • Anchoring: Left, Top
                              Perform Script [ “CreateDatabase” ]

                              Scripts:


                              Button PropertiesCoordinatesScript/Script Step
                                Type:
                              • Text: Export selected record to SQLite database
                              • Top: 14 pt
                              • Left: 171 pt
                              • Bottom: 38 pt
                              • Right: 437 pt
                              • Anchoring: Left, Top
                              Perform Script [ “ExportRecord” ]

                              Scripts:


                              Button PropertiesCoordinatesScript/Script Step
                                Type:
                              • Text: Import Records from SQLite Database
                              • Top: 15 pt
                              • Left: 449 pt
                              • Bottom: 38 pt
                              • Right: 683 pt
                              • Anchoring: Left, Top
                              Perform Script [ “Import” ]

                              Scripts:


                              Script Hierarchy

                              CreateDatabase
                              ExportRecord
                              Import
                              OpenDatabase
                              -
                              ExportRecord with JSON
                              Show records as JSON
                              Show each record as JSON

                              Next Script: [ExportRecord]
                              Script NameCreateDatabase
                              Run script with full access privilegesOff
                              Include In MenuYes
                              Layouts that use this script
                              Scripts that use this script
                                Script Definition
                                Script Steps
                                • Perform Script [ “OpenDatabase” ]
                                • Set Variable [ $Connection; Value:Get (ScriptResult) ]
                                • #Set encoding to be UTF-8
                                • Set Variable [ $Command; Value:MBS("SQL.NewCommand"; $Connection; "PRAGMA encoding = \"UTF-8\";") ]
                                • Set Variable [ $result; Value:MBS("SQL.Execute"; $Command) ]
                                • Set Variable [ $result2; Value:MBS("SQL.FreeCommand"; $Command) ]
                                • #Create a table
                                • Set Variable [ $Command; Value:MBS("SQL.NewCommand"; $Connection; "CREATE TABLE Test(FirstName VARCHAR, LastName VARCHAR, Birthday date, NumberOfOrders integer, TotalSales double)") ]
                                • Set Variable [ $result; Value:MBS("SQL.Execute"; $Command) ]
                                • Set Variable [ $result2; Value:MBS("SQL.Commit"; $Connection) ]
                                • Set Variable [ $result2; Value:MBS("SQL.FreeCommand"; $Command) ]
                                • If [ $result ≠ "OK" ]
                                • Show Custom Dialog [ Message: "Error: " & $result; Default Button: “OK”, Commit: “Yes”; Button 2: “Abbrechen”, Commit: “No” ]
                                • Else
                                • Show Custom Dialog [ Message: "Database created."; Default Button: “OK”, Commit: “Yes”; Button 2: “Abbrechen”, Commit: “No” ]
                                • End If
                                • Set Variable [ $result2; Value:MBS("SQL.FreeConnection"; $Connection) ]
                                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: [CreateDatabase]Next Script: [Import]
                                            Script NameExportRecord
                                            Run script with full access privilegesOff
                                            Include In MenuYes
                                            Layouts that use this script
                                            Scripts that use this script
                                              Script Definition
                                              Script Steps
                                              • Perform Script [ “OpenDatabase” ]
                                              • Set Variable [ $Connection; Value:Get (ScriptResult) ]
                                              • #Create insert command with setting values
                                              • Set Variable [ $Command; Value:MBS("SQL.NewCommand"; $Connection; "INSERT INTO 'Test' (FirstName, LastName, Birthday, NumberOfOrders, TotalSales) VALUES (:1,:2,:3,:4,:5)") ]
                                              • Set Variable [ $result; Value:MBS("SQL.SetParamAsText"; $Command; 1; SQLite fun::FirstName) ]
                                              • Set Variable [ $result; Value:MBS("SQL.SetParamAsText"; $Command; 2; SQLite fun::LastName) ]
                                              • Set Variable [ $result; Value:MBS("SQL.SetParamAsDate"; $Command; 3; SQLite fun::Birthday) ]
                                              • Set Variable [ $result; Value:MBS("SQL.SetParamAsNumber"; $Command; 4; SQLite fun::NumberOfOrders) ]
                                              • Set Variable [ $result; Value:MBS("SQL.SetParamAsFloat"; $Command; 5; SQLite fun::TotalSales) ]
                                              • #Run it
                                              • Set Variable [ $result; Value:MBS("SQL.Execute"; $Command) ]
                                              • #Cleanup
                                              • Set Variable [ $result2; Value:MBS("SQL.Commit"; $Connection) ]
                                              • Set Variable [ $result2; Value:MBS("SQL.FreeCommand"; $Command) ]
                                              • If [ $result ≠ "OK" ]
                                              • Show Custom Dialog [ Message: "Error: " & $result; Default Button: “OK”, Commit: “No”; Button 2: “Abbrechen”, Commit: “No” ]
                                              • Else
                                              • Show Custom Dialog [ Message: "Record exported."; Default Button: “OK”, Commit: “Yes”; Button 2: “Abbrechen”, Commit: “No” ]
                                              • End If
                                              • Set Variable [ $result2; Value:MBS("SQL.FreeConnection"; $Connection) ]
                                              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: [ExportRecord]Next Script: [OpenDatabase]
                                                    Script NameImport
                                                    Run script with full access privilegesOff
                                                    Include In MenuYes
                                                    Layouts that use this script
                                                    Scripts that use this script
                                                      Script Definition
                                                      Script Steps
                                                      • Perform Script [ “OpenDatabase” ]
                                                      • Set Variable [ $Connection; Value:Get (ScriptResult) ]
                                                      • #Create select and run it
                                                      • Set Variable [ $Command; Value:MBS("SQL.NewCommand"; $Connection; "SELECT * FROM Test") ]
                                                      • #Run it
                                                      • Set Variable [ $result; Value:MBS("SQL.Execute"; $Command) ]
                                                      • If [ $result ≠ "OK" ]
                                                      • Show Custom Dialog [ Message: "Error: " & $result; Default Button: “OK”, Commit: “No”; Button 2: “Abbrechen”, Commit: “No” ]
                                                      • Else
                                                      • Loop
                                                      • Set Variable [ $result; Value:MBS("SQL.FetchNext"; $Command) ]
                                                      • Exit Loop If [ $result ≠ 1 ]
                                                      • New Record/Request
                                                      • Set Field [ SQLite fun::FirstName; MBS("SQL.GetFieldAsText"; $command; "FirstName") ]
                                                      • Set Field [ SQLite fun::LastName; MBS("SQL.GetFieldAsText"; $command; "LastName") ]
                                                      • Set Field [ SQLite fun::Birthday; MBS("SQL.GetFieldAsDate"; $command; "Birthday") ]
                                                      • Set Field [ SQLite fun::TotalSales; MBS("SQL.GetFieldAsFloat"; $command; "TotalSales") ]
                                                      • Set Field [ SQLite fun::NumberOfOrders; MBS("SQL.GetFieldAsNumber"; $command; "NumberOfOrders") ]
                                                      • Commit Records/Requests [ No dialog ]
                                                      • End Loop
                                                      • Show Custom Dialog [ Message: "Records imported."; Default Button: “OK”, Commit: “Yes”; Button 2: “Abbrechen”, Commit: “No” ]
                                                      • End If
                                                      • #Cleanup
                                                      • Set Variable [ $result2; Value:MBS("SQL.FreeCommand"; $Command) ]
                                                      • Set Variable [ $result2; Value:MBS("SQL.Commit"; $Connection) ]
                                                      • Set Variable [ $result2; Value:MBS("SQL.FreeConnection"; $Connection) ]
                                                      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: [Import]Next Script: [-]
                                                            Script NameOpenDatabase
                                                            Run script with full access privilegesOff
                                                            Include In MenuYes
                                                            Layouts that use this script
                                                              Scripts that use this script
                                                              Script Definition
                                                              Script Steps
                                                              • Set Variable [ $Connection; Value:MBS("SQL.NewConnection") ]
                                                              • #Tell plugin where SQLite library is
                                                              • // Set Variable [ $result; Value:MBS("SQL.SetConnectionOption"; $Connection; "SQLITE.LIBS"; SQLite fun::PathToSQLiteLibrary) ]
                                                              • Set Variable [ $result; Value:MBS("SQL.InternalSQLiteLibrary.Activate") ]
                                                              • #Tell plugin we want to use SQLite
                                                              • Set Variable [ $result; Value:MBS("SQL.SetClient"; $Connection; "SQLite") ]
                                                              • #Connect to database in read/write/create mode. Creates new file if none exists.
                                                              • Set Variable [ $result; Value:MBS("SQL.Connect"; $Connection; SQLite fun::PathToSQLiteDatabase) ]
                                                              • If [ $result = "OK" ]
                                                              • Exit Script [ Result: $Connection ]
                                                              • Else
                                                              • Show Custom Dialog [ Message: "Error: " & $result; Default Button: “OK”, Commit: “Yes”; Button 2: “Abbrechen”, Commit: “No” ]
                                                              • Set Variable [ $result; Value:MBS("SQL.FreeConnection"; $Connection) ]
                                                              • Halt Script
                                                              • 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: [OpenDatabase]Next Script: [ExportRecord with JSON]
                                                                      Script Name-
                                                                      Run script with full access privilegesOff
                                                                      Include In MenuYes
                                                                      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: [-]Next Script: [Show records as JSON]
                                                                                          Script NameExportRecord with JSON
                                                                                          Run script with full access privilegesOff
                                                                                          Include In MenuYes
                                                                                          Layouts that use this script
                                                                                            Scripts that use this script
                                                                                              Script Definition
                                                                                              Script Steps
                                                                                              • Perform Script [ “OpenDatabase” ]
                                                                                              • Set Variable [ $Connection; Value:Get (ScriptResult) ]
                                                                                              • #Create insert command with setting values
                                                                                              • Set Variable [ $Command; Value:MBS("SQL.NewCommand"; $Connection; "INSERT INTO 'Test' (FirstName, LastName, Birthday, NumberOfOrders, TotalSales) VALUES (:FirstName,:LastName,:Birthday,:NumberOfOrders,:TotalSales)") ]
                                                                                              • Set Variable [ $json; Value:"{}" ]
                                                                                              • Set Variable [ $json; Value:MBS( "JSON.AddStringToObject"; $json; "FirstName"; SQLite fun::FirstName ) ]
                                                                                              • Set Variable [ $json; Value:MBS( "JSON.AddStringToObject"; $json; "LastName"; SQLite fun::LastName ) ]
                                                                                              • Set Variable [ $json; Value:MBS( "JSON.AddStringToObject"; $json; "Birthday"; SQLite fun::Birthday ) ]
                                                                                              • Set Variable [ $json; Value:MBS( "JSON.AddNumberToObject"; $json; "NumberOfOrders"; SQLite fun::NumberOfOrders ) ]
                                                                                              • Set Variable [ $json; Value:MBS( "JSON.AddNumberToObject"; $json; "TotalSales"; SQLite fun::TotalSales ) ]
                                                                                              • Set Variable [ $result; Value:MBS("SQL.SetParamsWithJSON"; $Command; $json) ]
                                                                                              • #Run it
                                                                                              • Show Custom Dialog [ Title: "JSON"; Message: MBS( "SQL.GetParamsAsJSON"; $Command ); Default Button: “OK”, Commit: “No”; Button 2: “Abbrechen”, Commit: “No” ]
                                                                                              • Set Variable [ $result; Value:MBS("SQL.Execute"; $Command) ]
                                                                                              • #Cleanup
                                                                                              • Set Variable [ $result2; Value:MBS("SQL.Commit"; $Connection) ]
                                                                                              • Set Variable [ $result2; Value:MBS("SQL.FreeCommand"; $Command) ]
                                                                                              • If [ $result ≠ "OK" ]
                                                                                              • Show Custom Dialog [ Message: "Error: " & $result; Default Button: “OK”, Commit: “No”; Button 2: “Abbrechen”, Commit: “No” ]
                                                                                              • Else
                                                                                              • Show Custom Dialog [ Message: "Record exported."; Default Button: “OK”, Commit: “Yes”; Button 2: “Abbrechen”, Commit: “No” ]
                                                                                              • End If
                                                                                              • Set Variable [ $result2; Value:MBS("SQL.FreeConnection"; $Connection) ]
                                                                                              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: [ExportRecord with JSON]Next Script: [Show each record as JSON]
                                                                                                    Script NameShow records as JSON
                                                                                                    Run script with full access privilegesOff
                                                                                                    Include In MenuYes
                                                                                                    Layouts that use this script
                                                                                                      Scripts that use this script
                                                                                                        Script Definition
                                                                                                        Script Steps
                                                                                                        • Perform Script [ “OpenDatabase” ]
                                                                                                        • Set Variable [ $Connection; Value:Get (ScriptResult) ]
                                                                                                        • #Create select and run it
                                                                                                        • Set Variable [ $Command; Value:MBS("SQL.NewCommand"; $Connection; "SELECT * FROM Test") ]
                                                                                                        • #Run it
                                                                                                        • Set Variable [ $result; Value:MBS("SQL.Execute"; $Command) ]
                                                                                                        • If [ $result ≠ "OK" ]
                                                                                                        • Show Custom Dialog [ Message: "Error: " & $result; Default Button: “OK”, Commit: “No”; Button 2: “Abbrechen”, Commit: “No” ]
                                                                                                        • Else
                                                                                                        • Show Custom Dialog [ Title: "JSON"; Message: MBS( "SQL.GetRecordsAsJSON"; $Command ); Default Button: “OK”, Commit: “No”; Button 2: “Abbrechen”, Commit: “No” ]
                                                                                                        • End If
                                                                                                        • #Cleanup
                                                                                                        • Set Variable [ $result2; Value:MBS("SQL.FreeCommand"; $Command) ]
                                                                                                        • Set Variable [ $result2; Value:MBS("SQL.FreeConnection"; $Connection) ]
                                                                                                        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 records as JSON]
                                                                                                                    Script NameShow each record as JSON
                                                                                                                    Run script with full access privilegesOff
                                                                                                                    Include In MenuYes
                                                                                                                    Layouts that use this script
                                                                                                                      Scripts that use this script
                                                                                                                        Script Definition
                                                                                                                        Script Steps
                                                                                                                        • Perform Script [ “OpenDatabase” ]
                                                                                                                        • Set Variable [ $Connection; Value:Get (ScriptResult) ]
                                                                                                                        • #Create select and run it
                                                                                                                        • Set Variable [ $Command; Value:MBS("SQL.NewCommand"; $Connection; "SELECT * FROM Test") ]
                                                                                                                        • #Run it
                                                                                                                        • Set Variable [ $result; Value:MBS("SQL.Execute"; $Command) ]
                                                                                                                        • If [ $result ≠ "OK" ]
                                                                                                                        • Show Custom Dialog [ Message: "Error: " & $result; Default Button: “OK”, Commit: “No”; Button 2: “Abbrechen”, Commit: “No” ]
                                                                                                                        • Else
                                                                                                                        • Loop
                                                                                                                        • Set Variable [ $result; Value:MBS("SQL.FetchNext"; $Command) ]
                                                                                                                        • Exit Loop If [ $result ≠ 1 ]
                                                                                                                        • Show Custom Dialog [ Title: "JSON"; Message: MBS( "SQL.GetFieldsAsJSON"; $Command ); Default Button: “OK”, Commit: “No”; Button 2: “Abbrechen”, Commit: “No” ]
                                                                                                                        • End Loop
                                                                                                                        • End If
                                                                                                                        • #Cleanup
                                                                                                                        • Set Variable [ $result2; Value:MBS("SQL.FreeCommand"; $Command) ]
                                                                                                                        • Set Variable [ $result2; Value:MBS("SQL.FreeConnection"; $Connection) ]
                                                                                                                        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: SQLite fun

                                                                                                                                    Used functions: