MBS FileMaker Plugin Example Databases

SQLite fun

All examples are included with download of MBS FileMaker Plugin.

SQLite fun.fmp12

Overview
Tables1
Relationships0
Layouts1
Scripts4
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, 3 records
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::FirstName
                              Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                              • Top: 114 pt
                              • Left: 138 pt
                              • Bottom: 128 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
                              Yes

                              Field Name: SQLite fun::LastName
                              Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                              • Top: 132 pt
                              • Left: 138 pt
                              • Bottom: 146 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
                              Yes

                              Field Name: SQLite fun::Birthday
                              Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                              • Top: 150 pt
                              • Left: 138 pt
                              • Bottom: 164 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
                              Yes

                              Field Name: SQLite fun::NumberOfOrders
                              Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                              • Top: 168 pt
                              • Left: 138 pt
                              • Bottom: 182 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
                              Yes

                              Field Name: SQLite fun::TotalSales
                              Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                              • Top: 186 pt
                              • Left: 138 pt
                              • Bottom: 200 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
                              Yes

                              Field Name: SQLite fun::PathToSQLiteLibrary
                              Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                              • Top: 66 pt
                              • Left: 138 pt
                              • Bottom: 80 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: 98 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

                              Group Buttons

                              Button PropertiesCoordinatesScript/Script Step
                                Type:
                              • Text: Create SQLite Database
                                Additional Properties:
                              • Change to hand cursor over button
                              • Rectangular
                              • Top: 12 pt
                              • Left: 12 pt
                              • Bottom: 38 pt
                              • Right: 163 pt
                              • Anchoring: Left, Top
                              Perform Script [ “CreateDatabase” ]

                              Scripts:


                              Button PropertiesCoordinatesScript/Script Step
                                Type:
                              • Text: Export selected record to SQLite database
                                Additional Properties:
                              • Change to hand cursor over button
                              • Rectangular
                              • Top: 12 pt
                              • Left: 175 pt
                              • Bottom: 38 pt
                              • Right: 444 pt
                              • Anchoring: Left, Top
                              Perform Script [ “ExportRecord” ]

                              Scripts:


                              Button PropertiesCoordinatesScript/Script Step
                                Type:
                              • Text: Import Records from SQLite Database
                                Additional Properties:
                              • Change to hand cursor over button
                              • Rectangular
                              • Top: 12 pt
                              • Left: 454 pt
                              • Bottom: 38 pt
                              • Right: 687 pt
                              • Anchoring: Left, Top
                              Perform Script [ “Import” ]

                              Scripts:


                              Button PropertiesCoordinatesScript/Script Step
                                Type:
                              • Text: Trace on
                                Additional Properties:
                              • Change to hand cursor over button
                              • Rectangular
                              • Top: 12 pt
                              • Left: 696 pt
                              • Bottom: 38 pt
                              • Right: 787 pt
                              • Anchoring: Left, Top
                              Set Variable [ $result; Value:MBS("Trace") ]

                              Script Hierarchy

                              CreateDatabase
                              ExportRecord
                              Import
                              OpenDatabase

                              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]
                                                            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 we want to use SQLite
                                                              • Set Variable [ $result; Value:MBS("SQL.SetClient"; $Connection; "SQLite") ]
                                                              • #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") ]
                                                              • #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

                                                                      Download example: SQLite fun

                                                                      Used functions:




                                                                      Links
                                                                      MBS Xojo Chart Plugins