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

MBS FileMaker Plugin Example Databases

Writing data

All examples are included with download of MBS FileMaker Plugin.

Writing data.fmp12

Overview
Tables1
Relationships0
Layouts1
Scripts5
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
Writing data
2 fields defined, 1 record
Writing data

Fields

Table Name: Writing data - 2 Fields
Field NameTypeOptionsCommentsOn LayoutsIn RelationshipsIn ScriptsIn Value Lists
OutputNormal, BinaryAuto-Enter:
  • Allow editing
Validation:
  • Only during data entry
Storage:
  • Repetitions: 1
      LogoNormal, BinaryAuto-Enter:
      • Allow editing
      Validation:
      • Only during data entry
      Storage:
      • Repetitions: 1

          Layout Objects: Writing data

          Regular Fields

          Field Name: Writing data::Output
          Field PropertiesCoordinatesField FormatField BehaviorQuick Find
          • Top: 24 pt
          • Left: 138 pt
          • Bottom: 149 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: Writing data::Logo
          Field PropertiesCoordinatesField FormatField BehaviorQuick Find
          • Top: 150 pt
          • Left: 138 pt
          • Bottom: 275 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

          Buttons

          Button PropertiesCoordinatesScript/Script Step
            Type:
          • Text: MBS Plugin Website
          • Top: 287 pt
          • Left: 15 pt
          • Bottom: 313 pt
          • Right: 168 pt
          • Anchoring: Left, Top
          Open URL [ "http://monkeybreadsoftware.de/filemaker/" ] [ No dialog ]

          Button PropertiesCoordinatesScript/Script Step
            Type:
          • Text: Order LibXL License
          • Top: 287 pt
          • Left: 176 pt
          • Bottom: 313 pt
          • Right: 329 pt
          • Anchoring: Left, Top
          Open URL [ "http://monkeybreadsoftware.de/filemaker/xl.shtml" ] [ No dialog ]

          Button PropertiesCoordinatesScript/Script Step
            Type:
          • Text: Create XLS File
          • Top: 28 pt
          • Left: 414 pt
          • Bottom: 63 pt
          • Right: 585 pt
          • Anchoring: Left, Top
          Perform Script [ “Create XLS” ]

          Scripts:


          Button PropertiesCoordinatesScript/Script Step
            Type:
          • Text: Create XLSX File
          • Top: 28 pt
          • Left: 608 pt
          • Bottom: 63 pt
          • Right: 779 pt
          • Anchoring: Left, Top
          Perform Script [ “Create XLSX” ]

          Scripts:


          Script Hierarchy

          Create XLS
          Create XLSX
          Create content
          InitXL
          Create XLSX to file

          Next Script: [Create XLSX]
          Script NameCreate XLS
          Run script with full access privilegesOff
          Include In MenuYes
          Layouts that use this script
          Scripts that use this script
            Script Definition
            Script Steps
            • If [ MBS("XL.IsInitialized") ≠ 1 ]
            • Perform Script [ “InitXL” ]
            • End If
            • #create new xls file
            • Set Variable [ $book; Value:MBS( "XL.NewBook"; 0 ) ]
            • Perform Script [ “Create content”; Parameter: $book ]
            • Set Field [ Writing data::Output; MBS("XL.Book.Save"; $book; "test.xls") ]
            • Set Variable [ $r; Value:MBS("XL.Book.Release"; $book) ]
            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: [Create XLS]Next Script: [Create content]
                  Script NameCreate XLSX
                  Run script with full access privilegesOff
                  Include In MenuYes
                  Layouts that use this script
                  Scripts that use this script
                    Script Definition
                    Script Steps
                    • If [ MBS("XL.IsInitialized") ≠ 1 ]
                    • Perform Script [ “InitXL” ]
                    • End If
                    • #create new xlsx file
                    • Set Variable [ $book; Value:MBS( "XL.NewBook"; 1 ) ]
                    • Perform Script [ “Create content”; Parameter: $book ]
                    • Set Field [ Writing data::Output; MBS("XL.Book.Save"; $book; "test.xlsx") ]
                    • Set Variable [ $r; Value:MBS("XL.Book.Release"; $book) ]
                    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: [Create XLSX]Next Script: [InitXL]
                          Script NameCreate content
                          Run script with full access privilegesOff
                          Include In MenuNo
                          Layouts that use this script
                            Scripts that use this script
                            Script Definition
                            Script Steps
                            • Set Variable [ $book; Value:Get(ScriptParameter) ]
                            • #load logo picture
                            • Set Variable [ $logoID; Value:MBS( "XL.Book.AddPictureContainer"; $book; Writing data::Logo) ]
                            • #create fonts
                            • Set Variable [ $textFont; Value:MBS( "XL.Book.AddFont"; $book) ]
                            • Set Variable [ $r; Value:MBS( "XL.Font.SetSize"; $book; $textfont; 8) ]
                            • Set Variable [ $r; Value:MBS( "XL.Font.SetName"; $book; $textfont; "Century Gothic") ]
                            • Set Variable [ $titleFont; Value:MBS( "XL.Book.AddFont"; $book) ]
                            • Set Variable [ $r; Value:MBS( "XL.Font.SetSize"; $book; $titleFont; 38) ]
                            • Set Variable [ $r; Value:MBS( "XL.Font.SetColor"; $book; $titlefont; 22) ]
                            • Set Variable [ $font12; Value:MBS( "XL.Book.AddFont"; $book; $textfont) ]
                            • Set Variable [ $r; Value:MBS( "XL.Font.SetSize"; $book; $font12; 12) ]
                            • Set Variable [ $font10; Value:MBS( "XL.Book.AddFont"; $book; $textfont) ]
                            • Set Variable [ $r; Value:MBS( "XL.Font.SetSize"; $book; $font10; 10) ]
                            • #create formats
                            • Set Variable [ $textFormat; Value:MBS( "XL.Book.AddFormat"; $book) ]
                            • Set Variable [ $r; Value:MBS( "XL.Format.SetFont"; $book; $textFormat; $textFont) ]
                            • Set Variable [ $r; Value:MBS( "XL.Format.SetAlignH"; $book; $textFormat; 1) // left ]
                            • Set Variable [ $titleFormat; Value:MBS( "XL.Book.AddFormat"; $book) ]
                            • Set Variable [ $r; Value:MBS( "XL.Format.SetFont"; $book; $titleFormat; $titleFont) ]
                            • Set Variable [ $r; Value:MBS( "XL.Format.SetAlignH"; $book; $titleFormat; 3) // right ]
                            • Set Variable [ $companyFormat; Value:MBS( "XL.Book.AddFormat"; $book) ]
                            • Set Variable [ $r; Value:MBS( "XL.Format.SetFont"; $book; $companyFormat; $font12) ]
                            • Set Variable [ $dateFormat; Value:MBS( "XL.Book.AddFormat"; $book; $textFormat) ]
                            • Set Variable [ $dateFormatID; Value:MBS( "XL.Book.AddCustomNumFormat"; $book; "mmmm\ d\,\ yyyy") ]
                            • Set Variable [ $r; Value:MBS( "XL.Format.SetNumFormat"; $book; $dateFormat; $dateFormatID) ]
                            • Set Variable [ $phoneFormat; Value:MBS( "XL.Book.AddFormat"; $book; $textFormat) ]
                            • Set Variable [ $phoneFormatID; Value:MBS( "XL.Book.AddCustomNumFormat"; $book; "[<=9999999]###\-####;\(###\)\ ###\-####") ]
                            • Set Variable [ $r; Value:MBS( "XL.Format.SetNumFormat"; $book; $phoneFormat; $phoneFormatID) ]
                            • Set Variable [ $borderFormat; Value:MBS( "XL.Book.AddFormat"; $book; $textFormat) ]
                            • Set Variable [ $r; Value:MBS( "XL.Format.SetBorder"; $book; $borderFormat) ]
                            • Set Variable [ $r; Value:MBS( "XL.Format.SetBorderColor"; $book; $borderFormat; 22) // ColorGray25 ]
                            • Set Variable [ $r; Value:MBS( "XL.Format.SetAlignV"; $book; $borderFormat; 1) // center ]
                            • Set Variable [ $percentFormat; Value:MBS( "XL.Book.AddFormat"; $book; $borderFormat) ]
                            • Set Variable [ $r; Value:MBS( "XL.Format.SetAlignH"; $book; $percentFormat; 3) // right ]
                            • Set Variable [ $percentFormatID; Value:MBS( "XL.Book.AddCustomNumFormat"; $book; "#%_)") ]
                            • Set Variable [ $r; Value:MBS( "XL.Format.SetNumFormat"; $book; $percentFormat; $percentFormatID) ]
                            • Set Variable [ $textRightFormat; Value:MBS( "XL.Book.AddFormat"; $book; $textFormat) ]
                            • Set Variable [ $r; Value:MBS( "XL.Format.SetAlignH"; $book; $textRightFormat; 3) // right ]
                            • Set Variable [ $r; Value:MBS( "XL.Format.SetAlignV"; $book; $textRightFormat; 1) // VCenter ]
                            • Set Variable [ $thankFormat; Value:MBS( "XL.Book.AddFormat"; $book; $textFormat) ]
                            • Set Variable [ $r; Value:MBS( "XL.Format.SetFont"; $book; $thankFormat; $font10) ]
                            • Set Variable [ $r; Value:MBS( "XL.Format.SetAlignH"; $book; $thankFormat; 2) // center ]
                            • Set Variable [ $dollarFormat; Value:MBS( "XL.Book.AddFormat"; $book; $borderFormat) ]
                            • Set Variable [ $dollarFormatID; Value:MBS( "XL.Book.AddCustomNumFormat"; $book; "_($* # ##0.00_);_($* (# ##0.00);_($* -??_);_(@_)") ]
                            • Set Variable [ $r; Value:MBS( "XL.Format.SetNumFormat"; $book; $dollarFormat; $dollarFormatID) ]
                            • Set Variable [ $r; Value:MBS( "XL.Format.SetAlignH"; $book; $dollarFormat; 3) // right ]
                            • #create sheet
                            • Set Variable [ $sheet; Value:MBS( "XL.Book.AddSheet"; $book; "Sales Receipt") ]
                            • Set Variable [ $r; Value:MBS( "XL.Sheet.SetDisplayGridlines"; $book; $sheet; 0 ) ]
                            • Set Variable [ $r; Value:MBS( "XL.Sheet.SetCol"; $book; $sheet; 1; 1; 36 ) ]
                            • Set Variable [ $r; Value:MBS( "XL.Sheet.SetCol"; $book; $sheet; 0; 0; 10 ) ]
                            • Set Variable [ $r; Value:MBS( "XL.Sheet.SetCol"; $book; $sheet; 2; 4; 11 ) ]
                            • Set Variable [ $r; Value:MBS( "XL.Sheet.setRow"; $book; $sheet; 2; 47,25 ) ]
                            • Set Variable [ $r; Value:MBS( "XL.Sheet.CellWriteText"; $book; $sheet; 2; 1; "Sales Receipt"; $titleFormat) ]
                            • Set Variable [ $r; Value:MBS( "XL.Sheet.SetMerge"; $book; $sheet; 2; 2; 1; 4) ]
                            • Set Variable [ $r; Value:MBS( "XL.Sheet.SetPictureWithSize"; $book; $sheet; 2; 1; $logoID; 100; 100) ]
                            • // Set Variable [ $r; Value:MBS( "XL.Sheet.SetPictureWithScale"; $book; $sheet; 2; 1; $logoID; ,2) ]
                            • Set Variable [ $r; Value:MBS( "XL.Sheet.CellWriteText"; $book; $sheet; 4; 0; "Apricot Ltd."; $companyFormat) ]
                            • Set Variable [ $r; Value:MBS( "XL.Sheet.CellWriteText"; $book; $sheet; 4; 3; "Date:"; $textFormat) ]
                            • Set Variable [ $r; Value:MBS( "XL.Sheet.CellWriteFormula"; $book; $sheet; 4; 4; "TODAY()"; $dateFormat) ]
                            • Set Variable [ $r; Value:MBS( "XL.Sheet.CellWriteText"; $book; $sheet; 5; 3; "Receipt #:"; $textFormat) ]
                            • Set Variable [ $r; Value:MBS( "XL.Sheet.CellWriteText"; $book; $sheet; 5; 4; 652; $textFormat) ]
                            • #write client address
                            • Set Variable [ $r; Value:MBS( "XL.Sheet.CellWriteText"; $book; $sheet; 8; 0; "Sold to:"; $textFormat) ]
                            • Set Variable [ $r; Value:MBS( "XL.Sheet.CellWriteText"; $book; $sheet; 8; 1; "John Smith"; $textFormat) ]
                            • Set Variable [ $r; Value:MBS( "XL.Sheet.CellWriteText"; $book; $sheet; 9; 1; "Pineapple Ltd,"; $textFormat) ]
                            • Set Variable [ $r; Value:MBS( "XL.Sheet.CellWriteText"; $book; $sheet; 10; 1; "123 Dreamland Street"; $textFormat) ]
                            • Set Variable [ $r; Value:MBS( "XL.Sheet.CellWriteText"; $book; $sheet; 11; 1; "Moema; 52674"; $textFormat) ]
                            • Set Variable [ $r; Value:MBS( "XL.Sheet.CellWriteNumber"; $book; $sheet; 12; 1; 2659872055; $phoneFormat) ]
                            • #write header line
                            • Set Variable [ $r; Value:MBS( "XL.Sheet.CellWriteText"; $book; $sheet; 14; 0; "Item #"; $textFormat) ]
                            • Set Variable [ $r; Value:MBS( "XL.Sheet.CellWriteText"; $book; $sheet; 14; 1; "Description"; $textFormat) ]
                            • Set Variable [ $r; Value:MBS( "XL.Sheet.CellWriteText"; $book; $sheet; 14; 2; "Qty"; $textFormat) ]
                            • Set Variable [ $r; Value:MBS( "XL.Sheet.CellWriteText"; $book; $sheet; 14; 3; "Unit Price"; $textFormat) ]
                            • Set Variable [ $r; Value:MBS( "XL.Sheet.CellWriteText"; $book; $sheet; 14; 4; "Line Total"; $textFormat) ]
                            • #prepare item rows
                            • Set Variable [ $row; Value:15 ]
                            • Loop
                            • Set Variable [ $r; Value:MBS( "XL.Sheet.setRow"; $book; $sheet; $row; 15 ) ]
                            • Set Variable [ $r; Value:MBS( "XL.Sheet.CellWriteBlank"; $book; $sheet; $row; 0; $borderFormat) ]
                            • Set Variable [ $r; Value:MBS( "XL.Sheet.CellWriteBlank"; $book; $sheet; $row; 1; $borderFormat) ]
                            • Set Variable [ $r; Value:MBS( "XL.Sheet.CellWriteBlank"; $book; $sheet; $row; 2; $borderFormat) ]
                            • Set Variable [ $r; Value:MBS( "XL.Sheet.CellWriteBlank"; $book; $sheet; $row; 3; $dollarFormat) ]
                            • Set Variable [ $rowString; Value:GetAsText($row+1) ]
                            • Set Variable [ $r; Value:MBS( "XL.Sheet.CellWriteFormula"; $book; $sheet; $row; 4;"IF(C" & $rowString & ">0;ABS(C" & $rowString & "*D" & $rowString & ");\"\")"; $dollarFormat) ]
                            • Set Variable [ $row; Value:$row + 1 ]
                            • Exit Loop If [ $row > 37 ]
                            • End Loop
                            • #Add bottom with sum and tax
                            • Set Variable [ $r; Value:MBS( "XL.Sheet.CellWriteText"; $book; $sheet; 38; 3; "Subtotal "; $textRightFormat) ]
                            • Set Variable [ $r; Value:MBS( "XL.Sheet.CellWriteText"; $book; $sheet; 39; 3; "Sales Tax "; $textRightFormat) ]
                            • Set Variable [ $r; Value:MBS( "XL.Sheet.CellWriteText"; $book; $sheet; 40; 3; "Total "; $textRightFormat) ]
                            • Set Variable [ $r; Value:MBS( "XL.Sheet.CellWriteFormula"; $book; $sheet; 38; 4; "SUM(E16:E38)"; $dollarFormat) ]
                            • Set Variable [ $r; Value:MBS( "XL.Sheet.CellWriteNumber"; $book; $sheet; 39; 4; ,2; $percentFormat) ]
                            • Set Variable [ $r; Value:MBS( "XL.Sheet.CellWriteFormula"; $book; $sheet; 40; 4; "E39+E39*E40"; $dollarFormat) ]
                            • Set Variable [ $r; Value:MBS( "XL.Sheet.setRow"; $book; $sheet; 38; 15) ]
                            • Set Variable [ $r; Value:MBS( "XL.Sheet.setRow"; $book; $sheet; 39; 15) ]
                            • Set Variable [ $r; Value:MBS( "XL.Sheet.setRow"; $book; $sheet; 40; 15) ]
                            • Set Variable [ $r; Value:MBS( "XL.Sheet.CellWriteText"; $book; $sheet; 42; 0; "Thank you for your business!"; $thankFormat) ]
                            • Set Variable [ $r; Value:MBS( "XL.Sheet.SetMerge"; $book; $sheet; 42; 42; 0; 4) ]
                            • #item 1
                            • Set Variable [ $r; Value:MBS( "XL.Sheet.CellWriteNumber"; $book; $sheet; 15; 0; 45; $borderFormat) ]
                            • Set Variable [ $r; Value:MBS( "XL.Sheet.CellWriteText"; $book; $sheet; 15; 1; "Grapes"; $borderFormat) ]
                            • Set Variable [ $r; Value:MBS( "XL.Sheet.CellWriteNumber"; $book; $sheet; 15; 2; 250; $borderFormat) ]
                            • Set Variable [ $r; Value:MBS( "XL.Sheet.CellWriteNumber"; $book; $sheet; 15; 3; 4,5; $dollarFormat) ]
                            • #item 2
                            • Set Variable [ $r; Value:MBS( "XL.Sheet.CellWriteNumber"; $book; $sheet; 16; 0; 12; $borderFormat) ]
                            • Set Variable [ $r; Value:MBS( "XL.Sheet.CellWriteText"; $book; $sheet; 16; 1; "Bananas"; $borderFormat) ]
                            • Set Variable [ $r; Value:MBS( "XL.Sheet.CellWriteNumber"; $book; $sheet; 16; 2; 480; $borderFormat) ]
                            • Set Variable [ $r; Value:MBS( "XL.Sheet.CellWriteNumber"; $book; $sheet; 16; 3; 1,4; $dollarFormat) ]
                            • #item 3
                            • Set Variable [ $r; Value:MBS( "XL.Sheet.CellWriteNumber"; $book; $sheet; 17; 0; 19; $borderFormat) ]
                            • Set Variable [ $r; Value:MBS( "XL.Sheet.CellWriteText"; $book; $sheet; 17; 1; "Apples"; $borderFormat) ]
                            • Set Variable [ $r; Value:MBS( "XL.Sheet.CellWriteNumber"; $book; $sheet; 17; 2; 180; $borderFormat) ]
                            • Set Variable [ $r; Value:MBS( "XL.Sheet.CellWriteNumber"; $book; $sheet; 17; 3; 2,8; $dollarFormat) ]
                            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: [Create content]Next Script: [Create XLSX to file]
                                    Script NameInitXL
                                    Run script with full access privilegesOff
                                    Include In MenuYes
                                    Layouts that use this script
                                      Scripts that use this script
                                      Script Definition
                                      Script Steps
                                      • #Find libXL and load it
                                      • #you can have libraries in container and export at runtime to folder of your choice.
                                      • #Or install library somewhere and pass path.
                                      • #If library is in same folder as plugin, you can only pass only file name.
                                      • If [ MBS("IsServer") ]
                                      • #Put the path you use for your server here:
                                      • If [ Get(SystemPlatform) = -2 ]
                                      • #Server on Windows
                                      • Set Variable [ $path; Value:"C:\Programs\FileMaker Server\libxl.dll" ]
                                      • Else If [ MBS("IsLinux") ]
                                      • #Server on Linux for FileMaker Cloud
                                      • Set Variable [ $path; Value:"/opt/FileMaker/FileMaker Server/libxl.so" ]
                                      • Else
                                      • #Server on Mac
                                      • Set Variable [ $path; Value: "/Library/FileMaker Server/libxl.dylib" ]
                                      • End If
                                      • Else
                                      • #For desktop and our examples we look in same folder as database:
                                      • Set Variable [ $databasePath; Value:Get(FilePath) ]
                                      • Set Variable [ $databasePath; Value:MBS("Path.FilemakerPathToNativePath"; $databasePath) ]
                                      • Set Variable [ $databasePath; Value:Substitute ( $databasePath ; ".fp7" ; ".fmp12") ]
                                      • Set Variable [ $databaseName; Value:Get(FileName) & ".fmp12" ]
                                      • If [ Get(SystemPlatform) = -2 ]
                                      • Set Variable [ $path; Value:Substitute ( $databasePath ; $databaseName ; "libxl.dll" ) ]
                                      • #plugin will look for libxl.dll and if not found also for libxl64.dll (64-bit) and libxl32.dll (32-bit).
                                      • Else
                                      • Set Variable [ $path; Value:Substitute ( $databasePath ; $databaseName ; "libxl.dylib" ) ]
                                      • #Mac dylib is usually 32 and 64 bit together.
                                      • End If
                                      • End If
                                      • #You can test for free.
                                      • #If you like to get a LibXL license, please follow links on our pricing page:
                                      • #https://www.monkeybreadsoftware.de/filemaker/pricing.shtml
                                      • Set Variable [ $LicenseeName; Value:"your name" ]
                                      • Set Variable [ $LicenseKey; Value:"your LibXL license key" ]
                                      • Set Variable [ $r; Value:MBS( "XL.Initialize"; $path; $LicenseeName; $LicenseKey) ]
                                      • If [ $r ≠ "OK" ]
                                      • Show Custom Dialog [ Title: "Error"; Message: $r; Default Button: “OK”, Commit: “No”; Button 2: “Cancel”, Commit: “No” ]
                                      • 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: [InitXL]
                                                    Script NameCreate XLSX to file
                                                    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

                                                              Download example: Writing data

                                                              Used functions: