MBS FileMaker Plugin Example Databases

TCP Receiver

All examples are included with download of MBS FileMaker Plugin.

TCP Receiver.fmp12

Overview
Tables1
Relationships0
Layouts1
Scripts6
Value Lists1
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
OnFirstWindowOpenScript: StartScript
OnLastWindowCloseOff
OnWindowOpenOff
OnWindowCloseOff
OnFileAVPlayerChangeOff
Thumbnail Settings
Generate ThumbnailsOn; Temporary

 

Tables

Table Name
Statistics
Occurrences in Relationship Graph
TCP Receiver
6 fields defined, 0 record
TCP Receiver

Fields

Table Name: TCP Receiver - 6 Fields
Field NameTypeOptionsCommentsOn LayoutsIn RelationshipsIn ScriptsIn Value Lists
PortNormal, NumberAuto-Enter:
  • Allow editing
Validation:
  • Only during data entry
Storage:
  • Repetitions: 1
  • Indexing: None
  • Automatically create indexes as needed
  • Index Language: German
      IPNormal, TextAuto-Enter:
      • Allow editing
      Validation:
      • Only during data entry
      Storage:
      • Repetitions: 1
      • Indexing: None
      • Automatically create indexes as needed
      • Index Language: German
          MessageNormal, TextAuto-Enter:
          • Allow editing
          Validation:
          • Only during data entry
          Storage:
          • Repetitions: 1
          • Indexing: None
          • Automatically create indexes as needed
          • Index Language: German
              ListenPortNormal, NumberAuto-Enter:
              • Allow editing
              Validation:
              • Only during data entry
              Storage:
              • Global
              • Repetitions: 1
              • Index Language: German
                  OptionsNormal, TextAuto-Enter:
                  • Allow editing
                  Validation:
                  • Only during data entry
                  Storage:
                  • Global
                  • Repetitions: 1
                  • Index Language: German
                      StatusNormal, TextAuto-Enter:
                      • Allow editing
                      Validation:
                      • Only during data entry
                      Storage:
                      • Global
                      • Repetitions: 1
                      • Index Language: German

                          Layout Objects: TCP Receiver

                          Regular Fields

                          Field Name: TCP Receiver::Port
                          Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                          • Top: 111 pt
                          • Left: 138 pt
                          • Bottom: 130 pt
                          • Right: 888 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: System Default
                          • Go to next field using: Tab key
                          Yes

                          Field Name: TCP Receiver::IP
                          Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                          • Top: 137 pt
                          • Left: 138 pt
                          • Bottom: 156 pt
                          • Right: 888 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: System Default
                          • Go to next field using: Tab key
                          Yes

                          Field Name: TCP Receiver::Message
                          Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                          • Top: 163 pt
                          • Left: 138 pt
                          • Bottom: 182 pt
                          • Right: 888 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: System Default
                          • Go to next field using: Tab key
                          Yes

                          Field Name: TCP Receiver::Options
                          Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                          • Top: 34 pt
                          • Left: 138 pt
                          • Bottom: 53 pt
                          • Right: 269 pt
                          • Anchoring: Left, Top
                          Field Format:
                          • Checkbox Set
                          • Display values from: Keep Open
                          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: TCP Receiver::ListenPort
                          Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                          • Top: 6 pt
                          • Left: 138 pt
                          • Bottom: 25 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
                          No

                          Field Name: TCP Receiver::Status
                          Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                          • Top: 74 pt
                          • Left: 366 pt
                          • Bottom: 93 pt
                          • Right: 619 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

                          Buttons

                          Button PropertiesCoordinatesScript/Script Step
                            Type:
                          • Text: Close Socket
                          • Top: 69 pt
                          • Left: 766 pt
                          • Bottom: 93 pt
                          • Right: 888 pt
                          • Anchoring: Left, Top
                          Perform Script [ “Close Socket” ]

                          Scripts:


                          Button PropertiesCoordinatesScript/Script Step
                            Type:
                          • Text: Create Socket and Listen
                          • Top: 69 pt
                          • Left: 138 pt
                          • Bottom: 93 pt
                          • Right: 318 pt
                          • Anchoring: Left, Top
                          Perform Script [ “CreateSocket” ]

                          Scripts:


                          Value Lists

                          Value List NameSourceValuesOn Layouts
                          Keep OpenCustom
                          • Keep Open

                          Script Hierarchy

                          CreateSocket
                          StartScript
                          ReadSomething
                          NewConnection
                          SocketError
                          Close Socket

                          Next Script: [StartScript]
                          Script NameCreateSocket
                          Run script with full access privilegesOff
                          Include In MenuYes
                          Layouts that use this script
                          Scripts that use this script
                            Script Definition
                            Script Steps
                            • If [ not (GetAsNumber($$sock) > 0) ]
                            • Set Variable [ $$sock; Value:MBS("Socket.NewTCPSocket") ]
                            • If [ MBS("IsError") ]
                            • Show Custom Dialog [ Title: "Failed to create Socket"; Message: $$sock; Default Button: “OK”, Commit: “No” ]
                            • Set Variable [ $$sock; Value:"" ]
                            • Exit Script [ ]
                            • End If
                            • Set Variable [ $r; Value:MBS("Socket.SetNewConnectionHandler"; $$sock; Get(FileName); "NewConnection") ]
                            • Set Variable [ $r; Value:MBS("Socket.SetErrorHandler"; $$sock; Get(FileName); "SocketError") ]
                            • Set Variable [ $r; Value:MBS("Socket.Listen"; $$sock; TCP Receiver::ListenPort) ]
                            • If [ MBS("IsError") ]
                            • Show Custom Dialog [ Title: "Failed to listen on Socket"; Message: $r; Default Button: “OK”, Commit: “No” ]
                            • Set Variable [ $$sock; Value:"" ]
                            • Exit Script [ ]
                            • Else
                            • Set Field [ TCP Receiver::Status; "Socket created." ]
                            • End If
                            • 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: [CreateSocket]Next Script: [ReadSomething]
                                    Script NameStartScript
                                    Run script with full access privilegesOff
                                    Include In MenuYes
                                    Layouts that use this script
                                      Scripts that use this script
                                        Script Definition
                                        Script Steps
                                        • Set Field [ TCP Receiver::Status; "" ]
                                        • Delete All Records [ No dialog ]
                                        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: [StartScript]Next Script: [NewConnection]
                                                Script NameReadSomething
                                                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 [ $sock; Value:Get(ScriptParameter) ]
                                                    • Set Variable [ $r; Value:MBS("Socket.Read"; $sock; 1500; "UTF-8") ]
                                                    • Set Variable [ $keepOpen; Value:Length ( TCP Receiver::Options ) > 0 ]
                                                    • If [ Left($r; 5) = "[MBS]" ]
                                                    • Show Custom Dialog [ Title: "Error Reading"; Message: $r; Default Button: “OK”, Commit: “Yes”; Button 2: “Cancel”, Commit: “No” ]
                                                    • Else If [ Length($r) = 0 ]
                                                    • // Show Custom Dialog [ Title: "Error Reading"; Message: "No data available."; Default Button: “OK”, Commit: “Yes”; Button 2: “Cancel”, Commit: “No” ]
                                                    • Else
                                                    • New Record/Request
                                                    • Set Field [ TCP Receiver::Message; $r ]
                                                    • Set Field [ TCP Receiver::IP; MBS("Socket.RemoteIP"; $sock) ]
                                                    • Set Field [ TCP Receiver::Port; MBS("Socket.RemotePort"; $sock) ]
                                                    • Set Field [ TCP Receiver::Status; "Socket received " & Get(CurrentHostTimestamp) ]
                                                    • Commit Records/Requests [ No dialog ]
                                                    • End If
                                                    • If [ $keepOpen ]
                                                    • #keep open and send something back
                                                    • Set Variable [ $r; Value:MBS("Socket.Write"; $sock; "Thank you."; "UTF-8") ]
                                                    • Else
                                                    • #close it
                                                    • Set Variable [ $r; Value:MBS("Socket.Close"; $sock) ]
                                                    • 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: [ReadSomething]Next Script: [SocketError]
                                                            Script NameNewConnection
                                                            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 [ $sock; Value:Get(ScriptParameter) ]
                                                                • Set Variable [ $newSock; Value:MBS("Socket.AcceptNewConnection"; $sock) ]
                                                                • If [ GetAsNumber($newSock) > 0 ]
                                                                • Set Variable [ $r; Value:MBS("Socket.SetErrorHandler"; $newsock; Get(FileName); "SocketError") ]
                                                                • Set Variable [ $r; Value:MBS("Socket.SetDataAvailableHandler"; $newsock; Get(FileName); "ReadSomething") ]
                                                                • Set Field [ TCP Receiver::Status; "Socket accepted connection " & Get(CurrentHostTimestamp) ]
                                                                • 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: [NewConnection]Next Script: [Close Socket]
                                                                        Script NameSocketError
                                                                        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 [ $sock; Value:Get(ScriptParameter) ]
                                                                            • Show Custom Dialog [ Title: "Socket Error"; Message: "For Socket " & $sock; Default Button: “OK”, Commit: “Yes”; Button 2: “Cancel”, Commit: “No” ]
                                                                            • Set Variable [ $r; Value:MBS("Socket.Close"; $sock) ]
                                                                            • Set Variable [ $$sock; Value:"" ]
                                                                            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: [SocketError]
                                                                                          Script NameClose Socket
                                                                                          Run script with full access privilegesOff
                                                                                          Include In MenuNo
                                                                                          Layouts that use this script
                                                                                          Scripts that use this script
                                                                                            Script Definition
                                                                                            Script Steps
                                                                                            • If [ GetAsNumber($$sock) > 0 ]
                                                                                            • Set Variable [ $r; Value:MBS("Socket.Close"; $$sock) ]
                                                                                            • Set Variable [ $$sock; Value:"" ]
                                                                                            • Set Field [ TCP Receiver::Status; "Socket closed." ]
                                                                                            • End If
                                                                                            Fields used in this script
                                                                                            Scripts used in this script
                                                                                              Layouts used in this script
                                                                                                Tables used in this script
                                                                                                Table occurrences used by this script
                                                                                                Custom Functions used by this script
                                                                                                  Custom menu set used by this script

                                                                                                    Download example: TCP Receiver

                                                                                                    Used functions:




                                                                                                    Links
                                                                                                    MBS Xojo Plugins