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

MBS FileMaker Plugin Example Databases

CoordinatDistance

All examples are included with download of MBS FileMaker Plugin.

CoordinatDistance.fmp12

Overview
Tables1
Relationships0
Layouts3
Scripts3
Value Lists0
Custom Functions0
Custom Menus0
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
distance_calculation
10 fields defined, 1 record
distance_calculation

Fields

Table Name: distance_calculation - 10 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
Unique identifier of each record in this table
          CreationTimestampNormal, TimestampAuto-Enter:
          • Creation timestamp
          Validation:
          • Only during data entry
          • Strict data type: 4 digit year
          • Not empty
          • Strict validation
          Storage:
          • Repetitions: 1
          • Indexing: None
          • Automatically create indexes as needed
          • Index Language: German
          Date and time each record was created
                  CreatedByNormal, TextAuto-Enter:
                  • Creation account name
                  Validation:
                  • Only during data entry
                  • Not empty
                  • Strict validation
                  Storage:
                  • Repetitions: 1
                  • Indexing: None
                  • Automatically create indexes as needed
                  • Index Language: German
                  Account name of the user who created each record
                          ModificationTimestampNormal, TimestampAuto-Enter:
                          • Modification timestamp
                          Validation:
                          • Only during data entry
                          • Strict data type: 4 digit year
                          • Not empty
                          • Strict validation
                          Storage:
                          • Repetitions: 1
                          • Indexing: None
                          • Automatically create indexes as needed
                          • Index Language: German
                          Date and time each record was last modified
                                  ModifiedByNormal, TextAuto-Enter:
                                  • Modification account name
                                  Validation:
                                  • Only during data entry
                                  • Not empty
                                  • Strict validation
                                  Storage:
                                  • Repetitions: 1
                                  • Indexing: None
                                  • Automatically create indexes as needed
                                  • Index Language: German
                                  Account name of the user who last modified each record
                                          distanceNormal, TextAuto-Enter:
                                          • Allow editing
                                          Validation:
                                          • Only during data entry
                                          Storage:
                                          • Repetitions: 1
                                          • Indexing: None
                                          • Automatically create indexes as needed
                                          • Index Language: German
                                              longitude 1Normal, NumberAuto-Enter:
                                              • Allow editing
                                              Validation:
                                              • Only during data entry
                                              Storage:
                                              • Repetitions: 1
                                              • Indexing: None
                                              • Automatically create indexes as needed
                                              • Index Language: German
                                                  latitude 1Normal, NumberAuto-Enter:
                                                  • Allow editing
                                                  Validation:
                                                  • Only during data entry
                                                  Storage:
                                                  • Repetitions: 1
                                                  • Indexing: None
                                                  • Automatically create indexes as needed
                                                  • Index Language: German
                                                      latitude 2Normal, NumberAuto-Enter:
                                                      • Allow editing
                                                      Validation:
                                                      • Only during data entry
                                                      Storage:
                                                      • Repetitions: 1
                                                      • Indexing: None
                                                      • Automatically create indexes as needed
                                                      • Index Language: German
                                                          longitude 2Normal, NumberAuto-Enter:
                                                          • Allow editing
                                                          Validation:
                                                          • Only during data entry
                                                          Storage:
                                                          • Repetitions: 1
                                                          • Indexing: None
                                                          • Automatically create indexes as needed
                                                          • Index Language: German

                                                              Layout Objects: distance_calculation

                                                              Regular Fields

                                                              Field Name: distance_calculation::distance
                                                              Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                                                              • Top: 193 pt
                                                              • Left: 138 pt
                                                              • Bottom: 214 pt
                                                              • Right: 391 pt
                                                              • Anchoring: Left, Top
                                                              Field Format:
                                                              • Edit Box
                                                              Field Behavior:
                                                              • Allow field to be entered: In Find mode, In Browse mode
                                                              • Touch keyboard type: Default for Data Type
                                                              • Go to next field using: Tab key
                                                              Yes

                                                              Field Name: distance_calculation::longitude 1
                                                              Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                                                              • Top: 99 pt
                                                              • Left: 138 pt
                                                              • Bottom: 120 pt
                                                              • Right: 217 pt
                                                              • Anchoring: Left, Top
                                                              Field Format:
                                                              • Edit Box
                                                              Field Behavior:
                                                              • Allow field to be entered: In Find mode, In Browse mode
                                                              • Touch keyboard type: Default for Data Type
                                                              • Go to next field using: Tab key
                                                              Yes

                                                              Field Name: distance_calculation::latitude 1
                                                              Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                                                              • Top: 75 pt
                                                              • Left: 138 pt
                                                              • Bottom: 96 pt
                                                              • Right: 217 pt
                                                              • Anchoring: Left, Top
                                                              Field Format:
                                                              • Edit Box
                                                              Field Behavior:
                                                              • Allow field to be entered: In Find mode, In Browse mode
                                                              • Touch keyboard type: Default for Data Type
                                                              • Go to next field using: Tab key
                                                              Yes

                                                              Field Name: distance_calculation::latitude 2
                                                              Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                                                              • Top: 75 pt
                                                              • Left: 385 pt
                                                              • Bottom: 96 pt
                                                              • Right: 464 pt
                                                              • Anchoring: Left, Top
                                                              Field Format:
                                                              • Edit Box
                                                              Field Behavior:
                                                              • Allow field to be entered: In Find mode, In Browse mode
                                                              • Touch keyboard type: Default for Data Type
                                                              • Go to next field using: Tab key
                                                              Yes

                                                              Field Name: distance_calculation::longitude 2
                                                              Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                                                              • Top: 98 pt
                                                              • Left: 385 pt
                                                              • Bottom: 119 pt
                                                              • Right: 464 pt
                                                              • Anchoring: Left, Top
                                                              Field Format:
                                                              • Edit Box
                                                              Field Behavior:
                                                              • Allow field to be entered: In Find mode, In Browse mode
                                                              • Touch keyboard type: Default for Data Type
                                                              • Go to next field using: Tab key
                                                              Yes

                                                              Buttons

                                                              Button PropertiesCoordinatesScript/Script Step
                                                                Type:
                                                              • Text: Calculate Distance
                                                              • Top: 263 pt
                                                              • Left: 177 pt
                                                              • Bottom: 318 pt
                                                              • Right: 336 pt
                                                              • Anchoring: Left, Top
                                                              Perform Script [ “distance_two_functions_in_environment ” ]

                                                              Scripts:


                                                              Layout Objects: Punkte

                                                              Regular Fields

                                                              Field Name: <Missing Field>
                                                              Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                                                              • Top: 52 pt
                                                              • Left: 138 pt
                                                              • Bottom: 73 pt
                                                              • Right: 391 pt
                                                              • Anchoring: Left, Top
                                                              Field Format:
                                                              • Edit Box
                                                              Field Behavior:
                                                              • Allow field to be entered: In Find mode, In Browse mode
                                                              • Touch keyboard type: Default for Data Type
                                                              • Go to next field using: Tab key
                                                              Yes

                                                              Field Name: <Missing Field>
                                                              Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                                                              • Top: 75 pt
                                                              • Left: 138 pt
                                                              • Bottom: 96 pt
                                                              • Right: 217 pt
                                                              • Anchoring: Left, Top
                                                              Field Format:
                                                              • Edit Box
                                                              Field Behavior:
                                                              • Allow field to be entered: In Find mode, In Browse mode
                                                              • Touch keyboard type: Default for Data Type
                                                              • Go to next field using: Tab key
                                                              Yes

                                                              Field Name: <Missing Field>
                                                              Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                                                              • Top: 98 pt
                                                              • Left: 138 pt
                                                              • Bottom: 119 pt
                                                              • Right: 217 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

                                                              Layout Objects: Distancen

                                                              Regular Fields

                                                              Field Name: <Missing Field>
                                                              Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                                                              • Top: 52 pt
                                                              • Left: 138 pt
                                                              • Bottom: 73 pt
                                                              • Right: 391 pt
                                                              • Anchoring: Left, Top
                                                              Field Format:
                                                              • Edit Box
                                                              Field Behavior:
                                                              • Allow field to be entered: In Find mode, In Browse mode
                                                              • Touch keyboard type: Default for Data Type
                                                              • Go to next field using: Tab key
                                                              Yes

                                                              Script Hierarchy

                                                              distance_two_functions_in_environment
                                                              distance_evaluate_static_JS_Code
                                                              distance_evaluate_with_global_properties

                                                              Next Script: [distance_evaluate_static_JS_Code]
                                                              Script Namedistance_two_functions_in_environment
                                                              Run script with full access privilegesOff
                                                              Include In MenuYes
                                                              Layouts that use this script
                                                              Scripts that use this script
                                                                Script Definition
                                                                Script Steps
                                                                • #calculate the distance between two coordinates with two functions we set in the environment
                                                                • #New JavaScript environment
                                                                • Set Variable [ $js; Value:MBS( "JS.New" ) ]
                                                                • #Add functions to environment
                                                                • Set Variable [ $r; Value:MBS( "JS.AddFunction"; $js; "DegToRad"; "function( deg ) { return deg * Math.PI / 180; }" ) ]
                                                                • Set Variable [ $r; Value:MBS( "JS.AddFunction"; $js; "distance"; "function( lat1, lon1, lat2, lon2 ) {lat1 = DegToRad(lat1);lat2 = DegToRad(lat2);lon1 = DegToRad(lon1);lon2 = DegToRad(lon2);var R = 6371; var x = (lon2-lon1) * Math.cos((lat1+lat2)/2); var y = (lat2-lat1); var d = Math.sqrt(x*x + y*y) * R;return d;}" ) ]
                                                                • #Set the variables for the function parameters. Read as number and encode for JSON
                                                                • Set Variable [ $lat1; Value:MBS( "JSON.CreateNumber"; GetAsNumber ( distance_calculation::latitude 1)) ]
                                                                • Set Variable [ $lon1; Value:MBS( "JSON.CreateNumber"; GetAsNumber ( distance_calculation::longitude 1)) ]
                                                                • Set Variable [ $lat2; Value:MBS( "JSON.CreateNumber"; GetAsNumber ( distance_calculation::latitude 2)) ]
                                                                • Set Variable [ $lon2; Value:MBS( "JSON.CreateNumber"; GetAsNumber ( distance_calculation::longitude 2)) ]
                                                                • #Call the distance JS function
                                                                • Set Variable [ $res; Value:MBS( "JS.CallFunction"; $js; "distance"; $lat1;$lon1;$lat2;$lon2 ) ]
                                                                • #Set the result
                                                                • Set Field [ distance_calculation::distance; $res ]
                                                                • #release the environment
                                                                • Set Variable [ $r; Value:MBS( "JS.Free"; $js ) ]
                                                                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: [distance_two_functions_in_environment ]Next Script: [distance_evaluate_with_global_properties]
                                                                        Script Namedistance_evaluate_static_JS_Code
                                                                        Run script with full access privilegesOff
                                                                        Include In MenuYes
                                                                        Layouts that use this script
                                                                          Scripts that use this script
                                                                            Script Definition
                                                                            Script Steps
                                                                            • #Evaluate a static JavaScript code
                                                                            • #New JavaScript environment
                                                                            • Set Variable [ $js; Value:MBS( "JS.New" ) ]
                                                                            • #Evaluate the JavaScript
                                                                            • Set Variable [ $r; Value:MBS( "JS.EvaluateToString"; $js; "function DegToRad( deg ) { return deg * Math.PI / 180; } function distance( lat1, lon1, lat2, lon2 ) { var R = 6371; lat1 = DegToRad(lat1); lat2 = DegToRad(lat2); lon1 = DegToRad(lon1); lon2 = DegToRad(lon2); var x = (lon2-lon1) * Math.cos((lat1+lat2)/2); var y = (lat2-lat1); var d = Math.sqrt(x*x + y*y) * R; return d; } distance( 50.73743, 7.0982068, 50.61, 7.2025 );" ) ]
                                                                            • #Show the result
                                                                            • Show Custom Dialog [ Title: "The distance"; Message: "The distance is "&$r&" kilometers"; Default Button: “OK”, Commit: “Yes” ]
                                                                            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: [distance_evaluate_static_JS_Code]
                                                                                          Script Namedistance_evaluate_with_global_properties
                                                                                          Run script with full access privilegesOff
                                                                                          Include In MenuYes
                                                                                          Layouts that use this script
                                                                                            Scripts that use this script
                                                                                              Script Definition
                                                                                              Script Steps
                                                                                              • #Calculates the distance between two coordinates whose values are defined in global JS variables
                                                                                              • #New JavaScript environment
                                                                                              • Set Variable [ $js; Value:MBS( "JS.New" ) ]
                                                                                              • #Set global properties by passing JSON text:
                                                                                              • // Set Variable [ $r; Value:MBS( "JS.SetGlobalProperty"; $js; "lat1"; "50.73743" ) ]
                                                                                              • // Set Variable [ $r; Value:MBS( "JS.SetGlobalProperty"; $js; "lon1"; "7.0982068" ) ]
                                                                                              • // Set Variable [ $r; Value:MBS( "JS.SetGlobalProperty"; $js; "lat2"; "50.61" ) ]
                                                                                              • // Set Variable [ $r; Value:MBS( "JS.SetGlobalProperty"; $js; "lon2"; "7.2025" ) ]
                                                                                              • #Set global properties by passing values directly:
                                                                                              • Set Variable [ $r; Value:MBS( "JS.SetGlobalPropertyValue"; $js; "lat1"; 50,73743 ) ]
                                                                                              • Set Variable [ $r; Value:MBS( "JS.SetGlobalPropertyValue"; $js; "lon1"; 7,0982068 ) ]
                                                                                              • Set Variable [ $r; Value:MBS( "JS.SetGlobalPropertyValue"; $js; "lat2"; 50,61 ) ]
                                                                                              • Set Variable [ $r; Value:MBS( "JS.SetGlobalPropertyValue"; $js; "lon2"; 7,2025 ) ]
                                                                                              • #Evaluate the JS code with the global property values
                                                                                              • Set Variable [ $r; Value:MBS( "JS.EvaluateToString"; $js; "function DegToRad( deg ) { return deg * Math.PI / 180; } function distance( lat1, lon1, lat2, lon2 ) { var R = 6371; lat1 = DegToRad(lat1); lat2 = DegToRad(lat2); lon1 = DegToRad(lon1); lon2 = DegToRad(lon2); var x = (lon2-lon1) * Math.cos((lat1+lat2)/2); var y = (lat2-lat1); var d = Math.sqrt(x*x + y*y) * R; return d; } distance( lat1, lon1, lat2, lon2 );" ) ]
                                                                                              • #Show the result
                                                                                              • Show Custom Dialog [ Title: "The distance"; Message: "The distance is "&$r&" kilometers"; Default Button: “OK”, Commit: “Yes” ]
                                                                                              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: CoordinatDistance

                                                                                                            Used functions: