MBS FileMaker Plugin Example Databases

SQLite blob

All examples are included with download of MBS FileMaker Plugin.

SQLite blob.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
4 fields defined, 1 record
SQLite fun

Fields

Table Name: SQLite fun - 4 Fields
Field NameTypeOptionsCommentsOn LayoutsIn RelationshipsIn ScriptsIn Value Lists
NameNormal, TextAuto-Enter:
  • Allow editing
Validation:
  • Only during data entry
Storage:
  • Repetitions: 1
  • Indexing: None
  • Automatically create indexes as needed
  • Index Language: German
      ImageNormal, BinaryAuto-Enter:
      • Allow editing
      Validation:
      • Only during data entry
      Storage:
      • Repetitions: 1
          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::Name
                  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::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

                  Field Name: SQLite fun::Image
                  Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                  • Top: 132 pt
                  • Left: 138 pt
                  • Bottom: 257 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 TestImage(Name VARCHAR, Image BLOB)") ]
                    • 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 'TestImage' (Name, Image) VALUES (:1,:2)") ]
                                  • Set Variable [ $result; Value:MBS("SQL.SetParamAsText"; $Command; 1; SQLite fun::Name) ]
                                  • Set Variable [ $result; Value:MBS("SQL.SetParamAsContainer"; $Command; 2; SQLite fun::Image) ]
                                  • #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 TestImage") ]
                                          • #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::Name; MBS("SQL.GetFieldAsText"; $command; "Name") ]
                                          • Set Variable [ $t; Value:MBS("SQL.GetFieldAsJPEG"; $command; "Image"; "test.jpg") ]
                                          • Set Field [ SQLite fun::Image; $t ]
                                          • 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 blob

                                                          Used functions:




                                                          Links
                                                          MBS Xojo Plugins