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

MBS FileMaker Plugin Example Databases

Search Scripts

All examples are included with download of MBS FileMaker Plugin.

Search Scripts.fmp12

Overview
Tables1
Relationships0
Layouts1
Scripts7
Value Lists0
Custom Functions0
Custom Menus24
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
OnFirstWindowOpenScript: Install Hotkey
OnLastWindowCloseScript: Cleanup
OnWindowOpenOff
OnWindowCloseOff
OnFileAVPlayerChangeOff
Thumbnail Settings
Generate ThumbnailsOn; Temporary

 

Tables

Table Name
Statistics
Occurrences in Relationship Graph
Search Scripts
8 fields defined, 0 record
Search Scripts

Fields

Table Name: Search Scripts - 8 Fields
Field NameTypeOptionsCommentsOn LayoutsIn RelationshipsIn ScriptsIn Value Lists
PrimaryKeyNormal, TextAuto-Enter: Validation:
  • Only during data entry
  • Not empty
  • Unique
  • Strict validation
Storage:
  • Repetitions: 1
  • Indexing: Minimal
  • Automatically create indexes as needed
  • Index Language: Unicode Raw
          XMLNormal, TextAuto-Enter:
          • Allow editing
          Validation:
          • Only during data entry
          Storage:
          • Repetitions: 1
          • Indexing: All
          • Index Language: German
              RowNormal, NumberAuto-Enter:
              • Allow editing
              Validation:
              • Only during data entry
              Storage:
              • Repetitions: 1
              • Indexing: None
              • Automatically create indexes as needed
              • Index Language: German
                  TextNormal, TextAuto-Enter:
                  • Allow editing
                  Validation:
                  • Only during data entry
                  Storage:
                  • Repetitions: 1
                  • Indexing: All
                  • Index Language: German
                      SearchTextNormal, TextAuto-Enter:
                      • Allow editing
                      Validation:
                      • Only during data entry
                      Storage:
                      • Global
                      • Repetitions: 1
                      • Index Language: German
                          EnabledNormal, TextAuto-Enter:
                          • Allow editing
                          Validation:
                          • Only during data entry
                          Storage:
                          • Repetitions: 1
                          • Indexing: None
                          • Automatically create indexes as needed
                          • Index Language: German
                              DebugXMLNormal, TextAuto-Enter:
                              • Allow editing
                              Validation:
                              • Only during data entry
                              Storage:
                              • Global
                              • Repetitions: 1
                              • Index Language: German
                                  TypeIDNormal, NumberAuto-Enter:
                                  • Allow editing
                                  Validation:
                                  • Only during data entry
                                  Storage:
                                  • Repetitions: 1
                                  • Indexing: None
                                  • Automatically create indexes as needed
                                  • Index Language: German

                                      Layout Objects: Search Scripts

                                      Regular Fields

                                      Field Name: Search Scripts::Row
                                      Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                                      • Top: 113 pt
                                      • Left: 2 pt
                                      • Bottom: 145 pt
                                      • Right: 81 pt
                                      • Anchoring: Left, Top
                                      Field Format:
                                      • Edit Box
                                      Field Behavior:
                                      • Touch keyboard type: Default for Data Type
                                      • Go to next field using: Tab key
                                      Yes

                                      Field Name: Search Scripts::Text
                                      Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                                      • Top: 113 pt
                                      • Left: 92 pt
                                      • Bottom: 145 pt
                                      • Right: 939 pt
                                      • Anchoring: Left and Right, 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
                                      Conditional FormattingConditionFormat
                                      1.

                                        self:normal .self
                                        {
                                        color: rgba(24.7059%,41.1765%,11.7647%,1);
                                        }
                                        self:normal .icon
                                        {
                                        -fm-icon-color: rgba(0%,0%,0%,0);
                                        }
                                      2.

                                        self:normal .self
                                        {
                                        color: rgba(40.3922%,40.3922%,40.3922%,1);
                                        }
                                      3.

                                        self:normal .self
                                        {
                                        color: rgba(52.1569%,0%,68.6275%,1);
                                        }

                                      Field Name: Search Scripts::SearchText
                                      Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                                      • Top: 66 pt
                                      • Left: 151 pt
                                      • Bottom: 98 pt
                                      • Right: 450 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
                                      No

                                      Field Name: Search Scripts::DebugXML
                                      Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                                      • Top: 133 pt
                                      • Left: 845 pt
                                      • Bottom: 485 pt
                                      • Right: 1114 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
                                      No

                                      Field Name: Search Scripts::XML
                                      Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                                      • Top: 39 pt
                                      • Left: 649 pt
                                      • Bottom: 394 pt
                                      • Right: 916 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

                                      Group Buttons

                                      Button PropertiesCoordinatesScript/Script Step
                                        Type:
                                      • Top: 2 pt
                                      • Left: 946 pt
                                      • Bottom: 66 pt
                                      • Right: 1010 pt
                                      • Anchoring: Right, Top
                                      Open URL [ "https://www.monkeybreadsoftware.com/filemaker/" ] [ No dialog ]

                                      Buttons

                                      Button PropertiesCoordinatesScript/Script Step
                                        Type:
                                      • Text: Find
                                      • Top: 67 pt
                                      • Left: 474 pt
                                      • Bottom: 97 pt
                                      • Right: 604 pt
                                      • Anchoring: Left, Top
                                      Perform Script [ “Run Search” ]

                                      Scripts:


                                      Popover Buttons

                                      Popover Button PropertiesCoordinates
                                        Type:
                                      • Text: Debug
                                      • Top: 66 pt
                                      • Left: 939 pt
                                      • Bottom: 96 pt
                                      • Right: 1018 pt
                                      • Anchoring: Right, Top
                                      Popover PropertiesCoordinates
                                        Show Title Bar:
                                      • Yes
                                        Title:
                                      • "XML"
                                        Position:
                                      • Top
                                      • Top: 100 pt
                                      • Left: 834 pt
                                      • Bottom: 500 pt
                                      • Right: 1124 pt
                                      • Anchoring: Left, Top
                                      Popover Content
                                      Tab ControlsSlide ControlsFieldsButtonsPortalsWeb Viewer ControlsCharts
                                          Field Objects

                                          Popover Button PropertiesCoordinates
                                            Type:
                                          • Text: XML
                                          • Top: 116 pt
                                          • Left: 939 pt
                                          • Bottom: 145 pt
                                          • Right: 1018 pt
                                          • Anchoring: Right, Top
                                          Popover PropertiesCoordinates
                                            Show Title Bar:
                                          • Yes
                                            Title:
                                          • "XML"
                                            Position:
                                          • Left
                                          • Top: 5 pt
                                          • Left: 638 pt
                                          • Bottom: 405 pt
                                          • Right: 928 pt
                                          • Anchoring: Left, Top
                                          Popover Content
                                          Tab ControlsSlide ControlsFieldsButtonsPortalsWeb Viewer ControlsCharts
                                              Field Objects

                                              Script Hierarchy

                                              Install Hotkey
                                              Cleanup
                                              Search Script
                                              Search via Return Key
                                              Run Search
                                              Release All Hotkeys
                                              Clear

                                              Next Script: [Cleanup]
                                              Script NameInstall Hotkey
                                              Run script with full access privilegesOff
                                              Siri Shortcut VisibleOff
                                              Include In MenuYes
                                              Layouts that use this script
                                                Scripts that use this script
                                                  Script Definition
                                                  Script Steps
                                                  • #Register hotkey to search with F8
                                                  • #cleanup old one
                                                  • If [ $$hotkeyF8 ]
                                                  • Set Variable [ $r; Value:MBS("HotKey.Unregister"; $$HotkeyF8) ]
                                                  • Set Variable [ $$hotkeyF8; Value:"" ]
                                                  • End If
                                                  • #now register
                                                  • Set Variable [ $hotkey; Value:MBS("HotKey.Register"; "F8"; "") ]
                                                  • If [ MBS("IsError") ]
                                                  • Show Custom Dialog [ Title: "Failed to register hotkey!"; Message: $hotkey; Default Button: “OK”, Commit: “Yes” ]
                                                  • Exit Script [ ]
                                                  • Else
                                                  • #and set magic expression to run the search
                                                  • If [ MBS("IsWindows") ]
                                                  • Set Variable [ $r; Value:MBS( "HotKey.SetEvaluate"; $hotkey; "Let ([ r = MBS( \"RemoteControl.PressControlKey\"; 1 ); r = MBS( \"RemoteControl.PressKey\"; \"a\"); r = MBS( \"Time.Wait\"; 50 ); r = MBS( \"RemoteControl.PressKey\"; \"c\"); r = MBS( \"RemoteControl.PressControlKey\"; 0 ); r = MBS( \"Time.Wait\"; 50 ); xml = MBS( \"Clipboard.GetFileMakerData\"; \"ScriptStep\" ); e = MBS(\"FM.RunScript\"; \"" & Get(FileName) & "\"; \"Search Script\"; xml); r = If(MBS(\"IsError\"); MBS(\"Msgbox\"; \"Failed to run: \" & e & Char(13) & \"Check fmplugin permissions to run scripts.\" ); \"\") ]; 1 )"; 0 ) ]
                                                  • Else
                                                  • Set Variable [ $r; Value:MBS( "HotKey.SetEvaluate"; $hotkey; "Let ([ r = MBS( \"Menubar.RunMenuCommand\"; 57642 /* select all */ ); r = MBS( \"Time.Wait\"; 50 ); r = MBS( \"Menubar.RunMenuCommand\"; 57634 /* copy */ ); r = MBS( \"Time.Wait\"; 50 ); xml = MBS( \"Clipboard.GetFileMakerData\"; \"ScriptStep\" ); e = MBS(\"FM.RunScript\"; \"" & Get(FileName) & "\"; \"Search Script\"; xml); r = If(MBS(\"IsError\"); MBS(\"Msgbox\"; \"Failed to run: \" & e & Char(13) & \"Check fmplugin permissions to run scripts.\" ); \"\") ]; 1 )"; 0 ) ]
                                                  • End If
                                                  • Set Variable [ $$hotkeyF8; Value:$hotkey ]
                                                  • Truncate Table [ No dialog; Table: “Search Scripts” ]
                                                  • Set Field [ Search Scripts::DebugXML; "" ]
                                                  • Set Field [ Search Scripts::SearchText; "" ]
                                                  • 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: [Install Hotkey]Next Script: [Search Script]
                                                          Script NameCleanup
                                                          Run script with full access privilegesOff
                                                          Siri Shortcut VisibleOff
                                                          Include In MenuYes
                                                          Layouts that use this script
                                                            Scripts that use this script
                                                              Script Definition
                                                              Script Steps
                                                              • #Cleanup our hotkey, when file is closed
                                                              • If [ $$hotkeyF8 ]
                                                              • Set Variable [ $r; Value:MBS("HotKey.Unregister"; $$HotkeyF8) ]
                                                              • Set Variable [ $$hotkeyF8; Value:"" ]
                                                              • 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: [Cleanup]Next Script: [Search via Return Key]
                                                                            Script NameSearch Script
                                                                            Run script with full access privilegesOff
                                                                            Siri Shortcut VisibleOff
                                                                            Include In MenuNo
                                                                            Layouts that use this script
                                                                              Scripts that use this script
                                                                                Script Definition
                                                                                Script Steps
                                                                                • #Peform the search. This script is triggered via our Hotkey
                                                                                • Set Variable [ $xml; Value:Get(ScriptParameter) ]
                                                                                • #nothing to search?
                                                                                • If [ Length ( $xml ) = 0 ]
                                                                                • Beep
                                                                                • Exit Script [ ]
                                                                                • End If
                                                                                • Select Window [ Name: "Search Scripts"; Current file ]
                                                                                • Go to Layout [ “Search Scripts” ]
                                                                                • Show All Records
                                                                                • Delete All Records [ No dialog ]
                                                                                • Set Field [ Search Scripts::DebugXML; MBS("XML.Colorize"; MBS("XML.Format"; $xml)) ]
                                                                                • Set Variable [ $xmlRef; Value:MBS("XML.Parse"; $xml) ]
                                                                                • If [ MBS("IsError") = 0 ]
                                                                                • Set Variable [ $count; Value:MBS("XML.Query"; $xmlRef; "count(//Step)") ]
                                                                                • If [ MBS("IsError") ]
                                                                                • Else If [ $count > 0 ]
                                                                                • Set Variable [ $index; Value:1 ]
                                                                                • Loop [ Flush: Always ]
                                                                                • Set Variable [ $x; Value:MBS("XML.Query"; $xmlRef; "//Step[" & ($index) & "]") ]
                                                                                • Set Variable [ $name; Value:MBS("XML.Query"; $xmlRef; "//Step[" & $index & "]/@name"; ""; 2) ]
                                                                                • Set Variable [ $enabled; Value:MBS("XML.Query"; $xmlRef; "//Step[" & $index & "]/@enable"; ""; 2) ]
                                                                                • Set Variable [ $TypeID; Value:MBS("XML.Query"; $xmlRef; "//Step[" & $index & "]/@id"; ""; 2) ]
                                                                                • Set Variable [ $text; Value:MBS( "XML.ExtractText"; $x) ]
                                                                                • #handle some types to better show details
                                                                                • If [ $typeID = 89 // comment ]
                                                                                • Set Variable [ $name; Value:"# " ]
                                                                                • Else If [ $typeID = 6 // go to layout ]
                                                                                • Set Variable [ $layout; Value:MBS("XML.Query"; $xmlRef; "//Step[" & $index & "]/Layout/@name"; ""; 2) ]
                                                                                • Set Variable [ $name; Value:$name & " " & $layout ]
                                                                                • Else If [ $typeID = 141 ]
                                                                                • Set Variable [ $VariableName; Value:MBS("XML.Query"; $xmlRef; "//Step[" & $index & "]/Name"; ""; 2) ]
                                                                                • Set Variable [ $name; Value:$name & " " & $VariableName ]
                                                                                • End If
                                                                                • #Save script step as record
                                                                                • New Record/Request
                                                                                • Set Field [ Search Scripts::Row; $index ]
                                                                                • Set Field [ Search Scripts::XML; MBS("XML.Colorize"; $X) ]
                                                                                • Set Field [ Search Scripts::Text; $name & " " & $text ]
                                                                                • Set Field [ Search Scripts::Enabled; $enabled ]
                                                                                • Set Field [ Search Scripts::TypeID; $typeID ]
                                                                                • Commit Records/Requests
                                                                                • Set Variable [ $index; Value:$index + 1 ]
                                                                                • Exit Loop If [ $count < $index ]
                                                                                • End Loop
                                                                                • End If
                                                                                • Set Variable [ $r; Value:MBS("XML.Release"; $xmlRef) ]
                                                                                • Go to Field [ Search Scripts::SearchText ]
                                                                                • 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: [Search Script]Next Script: [Run Search]
                                                                                      Script NameSearch via Return Key
                                                                                      Run script with full access privilegesOff
                                                                                      Siri Shortcut VisibleOff
                                                                                      Include In MenuNo
                                                                                      Layouts that use this script
                                                                                        Scripts that use this script
                                                                                          Script Definition
                                                                                          Script Steps
                                                                                          • If [ Code ( Get ( TriggerKeystroke ) ) = 13 ]
                                                                                          • Perform Script [ “Run Search” ]
                                                                                          • Exit Script [ Result: False ]
                                                                                          • Else
                                                                                          • Exit Script [ Result: True ]
                                                                                          • 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: [Search via Return Key]Next Script: [Release All Hotkeys]
                                                                                                      Script NameRun Search
                                                                                                      Run script with full access privilegesOff
                                                                                                      Siri Shortcut VisibleOff
                                                                                                      Include In MenuNo
                                                                                                      Layouts that use this script
                                                                                                      Scripts that use this script
                                                                                                      Script Definition
                                                                                                      Script Steps
                                                                                                      • #perform the search when user clicks find button or pressed return key
                                                                                                      • Show All Records
                                                                                                      • If [ Length ( Search Scripts::SearchText ) > 0 ]
                                                                                                      • Enter Find Mode [ ]
                                                                                                      • #We search box XML and Text
                                                                                                      • Set Field [ Search Scripts::Text; Search Scripts::SearchText ]
                                                                                                      • New Record/Request
                                                                                                      • Set Field [ Search Scripts::XML; Search Scripts::SearchText ]
                                                                                                      • Perform Find [ ]
                                                                                                      • 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: [Run Search]Next Script: [Clear]
                                                                                                              Script NameRelease All Hotkeys
                                                                                                              Run script with full access privilegesOff
                                                                                                              Siri Shortcut VisibleOff
                                                                                                              Include In MenuNo
                                                                                                              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: [Release All Hotkeys]
                                                                                                                                Script NameClear
                                                                                                                                Run script with full access privilegesOff
                                                                                                                                Siri Shortcut VisibleOff
                                                                                                                                Include In MenuYes
                                                                                                                                Layouts that use this script
                                                                                                                                  Scripts that use this script
                                                                                                                                    Script Definition
                                                                                                                                    Script Steps
                                                                                                                                    • #Clear all records
                                                                                                                                    • Set Error Capture [ On ]
                                                                                                                                    • Truncate Table [ No dialog; Table: “Search Scripts” ]
                                                                                                                                    • Set Field [ Search Scripts::DebugXML; "" ]
                                                                                                                                    • Set Field [ Search Scripts::SearchText; "" ]
                                                                                                                                    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: Search Scripts

                                                                                                                                            Used functions: