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

MBS FileMaker Plugin Example Databases

RichTextToJSON

All examples are included with download of MBS FileMaker Plugin.

RichTextToJSON.fmp12

Overview
Tables1
Relationships0
Layouts2
Scripts11
Value Lists1
Custom Functions5
Custom Menus0
File Options
Default custom menu set[Standard FileMaker Menus]
When opening file
Minimum allowed version16.0
Login usingAccount Name; Account= Admin
Allow user to save passwordOff
Require iOS passcodeOff
Switch to layoutOff
Hide all toolbarsOff
Script triggers
OnFirstWindowOpenScript: on open
OnLastWindowCloseOff
OnWindowOpenOff
OnWindowCloseOff
OnFileAVPlayerChangeOff
Thumbnail Settings
Generate ThumbnailsOn; Temporary

 

Tables

Table Name
Statistics
Occurrences in Relationship Graph
DEMO
10 fields defined, 1 record
DEMO

Fields

Table Name: DEMO - 10 Fields
Field NameTypeOptionsCommentsOn LayoutsIn RelationshipsIn ScriptsIn Value Lists
IDNormal, TextAuto-Enter:
  • Context table: DEMO
    Calculation: Get( UUID )
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
          _Normal, NumberAuto-Enter:
          • Allow editing
          Validation:
          • Only during data entry
          Storage:
          • Repetitions: 1
          • Indexing: None
          • Automatically create indexes as needed
          • Index Language: English
                  RichTextSourceNormal, TextAuto-Enter:
                  • Allow editing
                  Validation:
                  • Only during data entry
                  Storage:
                  • Repetitions: 1
                  • Indexing: None
                  • Automatically create indexes as needed
                  • Index Language: English
                      EncodedResultNormal, TextAuto-Enter:
                      • Allow editing
                      Validation:
                      • Only during data entry
                      Storage:
                      • Repetitions: 2
                      • Indexing: None
                      • Automatically create indexes as needed
                      • Index Language: English
                          EncodingExecutionTimeNormal, NumberAuto-Enter:
                          • Allow editing
                          Validation:
                          • Only during data entry
                          Storage:
                          • Repetitions: 2
                          • Indexing: None
                          • Automatically create indexes as needed
                          • Index Language: English
                              DecodedResultNormal, TextAuto-Enter:
                              • Allow editing
                              Validation:
                              • Only during data entry
                              Storage:
                              • Repetitions: 2
                              • Indexing: None
                              • Automatically create indexes as needed
                              • Index Language: English
                                  DecodingExecutionTimeNormal, NumberAuto-Enter:
                                  • Allow editing
                                  Validation:
                                  • Only during data entry
                                  Storage:
                                  • Repetitions: 2
                                  • Indexing: None
                                  • Automatically create indexes as needed
                                  • Index Language: English
                                      PropertiesToEncodeNormal, TextAuto-Enter:
                                      • Allow editing
                                      Validation:
                                      • Only during data entry
                                      Storage:
                                      • Global
                                      • Repetitions: 1
                                      • Index Language: English
                                          ClipboardCopyNormal, TextAuto-Enter:
                                          • Allow editing
                                          Validation:
                                          • Only during data entry
                                          Storage:
                                          • Global
                                          • Repetitions: 1
                                          • Index Language: English
                                              Source_CSSCalculated, TextCalculation: Storage:
                                              • Repetitions: 1
                                              • Indexing: None
                                              • Automatically create indexes as needed
                                              • Index Language: English

                                                      Layout Objects: DEMO

                                                      Regular Fields

                                                      Field Name: DEMO::RichTextSource
                                                      Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                                                      • Top: 90 pt
                                                      • Left: 20 pt
                                                      • Bottom: 845 pt
                                                      • Right: 438 pt
                                                      • Anchoring: Left, Top and Bottom
                                                      Field Format:
                                                      • Edit Box
                                                      • Include vertical scrollbar
                                                      Field Behavior:
                                                      • Allow field to be entered: In Find mode, In Browse mode
                                                      • Disable visual spell-checking
                                                      • Touch keyboard type: Default for Data Type
                                                      • Go to next field using: Tab key
                                                      No

                                                      Field Name: DEMO::PropertiesToEncode
                                                      Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                                                        Tooltip:
                                                      • "Select the properties which should be included when creating JSON or FileMaker calculation representation of Rich Text."
                                                      • Top: 867 pt
                                                      • Left: 152 pt
                                                      • Bottom: 888 pt
                                                      • Right: 394 pt
                                                      • Anchoring: Left, Top
                                                      Field Format: 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: DEMO::EncodedResult
                                                      Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                                                      • Top: 90 pt
                                                      • Left: 645 pt
                                                      • Bottom: 440 pt
                                                      • Right: 1011 pt
                                                      • Anchoring: Left, Top
                                                      Field Format:
                                                      • Edit Box
                                                      • Include vertical scrollbar
                                                      • Show repetition: 1 through 1
                                                      • Orientation: vertical
                                                      Field Behavior:
                                                      • Allow field to be entered: In Find mode, In Browse mode
                                                      • Disable visual spell-checking
                                                      • Touch keyboard type: Default for Data Type
                                                      • Go to next field using: Tab key
                                                      No

                                                      Field Name: DEMO::ClipboardCopy
                                                      Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                                                      • Top: 41 pt
                                                      • Left: 1689 pt
                                                      • Bottom: 62 pt
                                                      • Right: 1768 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: DEMO::EncodedResult
                                                      Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                                                      • Top: 501 pt
                                                      • Left: 645 pt
                                                      • Bottom: 845 pt
                                                      • Right: 1011 pt
                                                      • Anchoring: Left, Top and Bottom
                                                      Field Format:
                                                      • Edit Box
                                                      • Include vertical scrollbar
                                                      • Show repetition: 2 through 2
                                                      • Orientation: vertical
                                                      Field Behavior:
                                                      • Allow field to be entered: In Find mode, In Browse mode
                                                      • Disable visual spell-checking
                                                      • Touch keyboard type: Default for Data Type
                                                      • Go to next field using: Tab key
                                                      No

                                                      Field Name: DEMO::DecodedResult
                                                      Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                                                      • Top: 90 pt
                                                      • Left: 1218 pt
                                                      • Bottom: 440 pt
                                                      • Right: 1584 pt
                                                      • Anchoring: Left and Right, Top
                                                      Field Format:
                                                      • Edit Box
                                                      • Include vertical scrollbar
                                                      • Show repetition: 1 through 1
                                                      • Orientation: vertical
                                                      Field Behavior:
                                                      • Allow field to be entered: In Find mode, In Browse mode
                                                      • Disable visual spell-checking
                                                      • Touch keyboard type: Default for Data Type
                                                      • Go to next field using: Tab key
                                                      No

                                                      Field Name: DEMO::DecodedResult
                                                      Field PropertiesCoordinatesField FormatField BehaviorQuick Find
                                                      • Top: 501 pt
                                                      • Left: 1218 pt
                                                      • Bottom: 845 pt
                                                      • Right: 1584 pt
                                                      • Anchoring: Left and Right, Top and Bottom
                                                      Field Format:
                                                      • Edit Box
                                                      • Include vertical scrollbar
                                                      • Show repetition: 2 through 2
                                                      • Orientation: vertical
                                                      Field Behavior:
                                                      • Allow field to be entered: In Find mode, In Browse mode
                                                      • Disable visual spell-checking
                                                      • Touch keyboard type: Default for Data Type
                                                      • Go to next field using: Tab key
                                                      No

                                                      Group Buttons

                                                      Button PropertiesCoordinatesScript/Script Step
                                                        Type:
                                                      • Text: https://community.filemaker.com/docs/DOC-9186
                                                        Additional Properties:
                                                      • Change to hand cursor over button
                                                      • Rectangular
                                                      • Top: 374 pt
                                                      • Left: 731 pt
                                                      • Bottom: 390 pt
                                                      • Right: 996 pt
                                                      • Anchoring: Left, Top
                                                      Open URL [ "https://community.filemaker.com/docs/DOC-9186" ] [ No dialog ]

                                                      Button PropertiesCoordinatesScript/Script Step
                                                        Type:
                                                      • Text: https://community.filemaker.com/people/steve_ssh
                                                        Additional Properties:
                                                      • Change to hand cursor over button
                                                      • Rectangular
                                                      • Top: 405 pt
                                                      • Left: 731 pt
                                                      • Bottom: 422 pt
                                                      • Right: 1003 pt
                                                      • Anchoring: Left, Top
                                                      Open URL [ "https://community.filemaker.com/people/steve_ssh" ] [ No dialog ]

                                                      Buttons

                                                      Button PropertiesCoordinatesScript/Script Step
                                                        Type:
                                                      • Text: Express as JSON
                                                        Tooltip:
                                                      • "Express the origially entered Rich Text as a JSON array."
                                                      • Top: 210 pt
                                                      • Left: 458 pt
                                                      • Bottom: 242 pt
                                                      • Right: 625 pt
                                                      • Anchoring: Left, Top
                                                      Perform Script [ “encode - json” ]

                                                      Scripts:


                                                      Button PropertiesCoordinatesScript/Script Step
                                                        Type:
                                                      • Text: Reset
                                                        Tooltip:
                                                      • "Clear all result fields."
                                                      • Top: 855 pt
                                                      • Left: 1513 pt
                                                      • Bottom: 887 pt
                                                      • Right: 1584 pt
                                                      • Anchoring: Right, Bottom
                                                      Perform Script [ “reset fields” ]

                                                      Scripts:


                                                      Button PropertiesCoordinatesScript/Script Step
                                                        Type:
                                                      • Text: Express as FMP Calc
                                                        Tooltip:
                                                      • "Translate the origially entered Rich Text into a FileMaker calculation which will evaluate back into the original text."
                                                      • Top: 641 pt
                                                      • Left: 458 pt
                                                      • Bottom: 673 pt
                                                      • Right: 625 pt
                                                      • Anchoring: Left, Top
                                                      Perform Script [ “encode - fmp_calc” ]

                                                      Scripts:


                                                      Button PropertiesCoordinatesScript/Script Step
                                                        Type:
                                                      • Text: Decode to Rich Text
                                                        Tooltip:
                                                      • "Translate the JSON representation of Rich Text back into its original value."
                                                      • Top: 210 pt
                                                      • Left: 1031 pt
                                                      • Bottom: 242 pt
                                                      • Right: 1198 pt
                                                      • Anchoring: Left, Top
                                                      Perform Script [ “decode - json” ]

                                                      Scripts:


                                                      Button PropertiesCoordinatesScript/Script Step
                                                        Type:
                                                      • Text: Evaluate to Rich Text
                                                        Tooltip:
                                                      • "Evalulate the FileMaker calculation to obtain the original Rich Text."
                                                      • Top: 641 pt
                                                      • Left: 1031 pt
                                                      • Bottom: 673 pt
                                                      • Right: 1198 pt
                                                      • Anchoring: Left, Top
                                                      Perform Script [ “decode - fmp_calc” ]

                                                      Scripts:


                                                      Button PropertiesCoordinatesScript/Script Step
                                                        Type:
                                                      • Text:
                                                        Tooltip:
                                                      • "Copy to clipboard."
                                                      • Top: 67 pt
                                                      • Left: 978 pt
                                                      • Bottom: 90 pt
                                                      • Right: 1009 pt
                                                      • Anchoring: Left, Top
                                                      Perform Script [ “set clipboard”; Parameter: DEMO::EncodedResult ]

                                                      Scripts:

                                                      Fields:


                                                      Button PropertiesCoordinatesScript/Script Step
                                                        Type:
                                                      • Text:
                                                        Tooltip:
                                                      • "Copy to clipboard."
                                                      • Top: 478 pt
                                                      • Left: 978 pt
                                                      • Bottom: 501 pt
                                                      • Right: 1009 pt
                                                      • Anchoring: Left, Top
                                                      Perform Script [ “set clipboard”; Parameter: DEMO::EncodedResult[2] ]

                                                      Scripts:

                                                      Fields:


                                                      Button PropertiesCoordinatesScript/Script Step
                                                        Type:
                                                      • Text:
                                                        Tooltip:
                                                      • "Copy to clipboard."
                                                      • Top: 67 pt
                                                      • Left: 1551 pt
                                                      • Bottom: 90 pt
                                                      • Right: 1582 pt
                                                      • Anchoring: Left, Top
                                                      Perform Script [ “set clipboard”; Parameter: DEMO::DecodedResult ]

                                                      Scripts:

                                                      Fields:


                                                      Button PropertiesCoordinatesScript/Script Step
                                                        Type:
                                                      • Text:
                                                        Tooltip:
                                                      • "Copy to clipboard."
                                                      • Top: 478 pt
                                                      • Left: 1551 pt
                                                      • Bottom: 501 pt
                                                      • Right: 1582 pt
                                                      • Anchoring: Left, Top
                                                      Perform Script [ “set clipboard”; Parameter: DEMO::DecodedResult[2] ]

                                                      Scripts:

                                                      Fields:


                                                      Popover Buttons

                                                      Popover Button PropertiesCoordinates
                                                        Type:
                                                      • Text: ?
                                                      • Top: 9 pt
                                                      • Left: 1543 pt
                                                      • Bottom: 41 pt
                                                      • Right: 1584 pt
                                                      • Anchoring: Right, Top
                                                      Popover PropertiesCoordinates
                                                        Show Title Bar:
                                                      • No
                                                        Position:
                                                      • Left
                                                      • Top: 5 pt
                                                      • Left: 697 pt
                                                      • Bottom: 484 pt
                                                      • Right: 1532 pt
                                                      • Anchoring: Left, Top
                                                      Popover Content
                                                      Tab ControlsSlide ControlsFieldsButtonsPortalsWeb Viewer ControlsCharts
                                                        • Text: https://community.filemaker.com/docs/DOC-9186-->Open URL [ "https://community.filemaker.com/docs/DOC-9186" ] [ No dialog ] at (374, 731, 390, 996)
                                                        • Text: https://community.filemaker.com/people/steve_ssh-->Open URL [ "https://community.filemaker.com/people/steve_ssh" ] [ No dialog ] at (405, 731, 422, 1003)

                                                        • Button Bars

                                                          Button Bar PropertiesCoordinates
                                                            Orientation:
                                                          • horizontal
                                                          • Top: 448 pt
                                                          • Left: 768 pt
                                                          • Bottom: 470 pt
                                                          • Right: 998 pt
                                                          • Anchoring: Left, Top

                                                          Button Bar PropertiesCoordinates
                                                            Orientation:
                                                          • horizontal
                                                          • Top: 66 pt
                                                          • Left: 20 pt
                                                          • Bottom: 90 pt
                                                          • Right: 438 pt
                                                          • Anchoring: Left, Top

                                                          Button Bar PropertiesCoordinates
                                                            Orientation:
                                                          • horizontal
                                                          • Top: 66 pt
                                                          • Left: 645 pt
                                                          • Bottom: 90 pt
                                                          • Right: 1011 pt
                                                          • Anchoring: Left, Top

                                                          Button Bar PropertiesCoordinates
                                                            Orientation:
                                                          • horizontal
                                                          • Top: 477 pt
                                                          • Left: 645 pt
                                                          • Bottom: 501 pt
                                                          • Right: 1011 pt
                                                          • Anchoring: Left, Top

                                                          Button Bar PropertiesCoordinates
                                                            Orientation:
                                                          • horizontal
                                                          • Top: 66 pt
                                                          • Left: 1218 pt
                                                          • Bottom: 90 pt
                                                          • Right: 1584 pt
                                                          • Anchoring: Left and Right, Top

                                                          Button Bar PropertiesCoordinates
                                                            Orientation:
                                                          • horizontal
                                                          • Top: 477 pt
                                                          • Left: 1218 pt
                                                          • Bottom: 501 pt
                                                          • Right: 1584 pt
                                                          • Anchoring: Left and Right, Top

                                                          Graphic Objects

                                                          Graphic Object PropertiesCoordinates
                                                            Type:
                                                          • Text: Please note that this file has only been tested on MacOS
                                                            Hide Condition:
                                                          • Get( SystemPlatform ) = 1
                                                          • Top: 17 pt
                                                          • Left: 645 pt
                                                          • Bottom: 36 pt
                                                          • Right: 1025 pt
                                                          • Anchoring: Left, Top

                                                          Layout Objects: Plug-In Alert

                                                          Value Lists

                                                          Value List NameSourceValuesOn Layouts
                                                          PropertiesCustom
                                                          • Font, Color, Size, Styles

                                                          Script Hierarchy

                                                          encode - json
                                                          encode - fmp_calc
                                                          -
                                                          decode - json
                                                          decode - fmp_calc
                                                          -
                                                          evaluate blocks of fmp calcs
                                                          -
                                                          on open
                                                          reset fields
                                                          set clipboard

                                                          Next Script: [encode - fmp_calc]
                                                          Script Nameencode - json
                                                          Run script with full access privilegesOff
                                                          Include In MenuNo
                                                          Layouts that use this script
                                                          Scripts that use this script
                                                            Script Definition
                                                            Script Steps
                                                            • #======================================================================================= Name: encode - json Purpose: Translates rich text field content into a block of JSON that describes the text's formatting. Dependencies: Uses custom function(s) which require a plug-in capable of evaluating a string of JavaScript. Context: ---------------------------------------------------------------- Input Params: (none) Output Values: (none) ---------------------------------------------------------------- Created: 2018-July - steve_ssh Comments: Possible plugins: bBox, BaseElements, MBS. Not tested on Windows. =======================================================================================
                                                            • Set Field [ DEMO::EncodingExecutionTime; "" ]
                                                            • Set Field [ DEMO::EncodedResult; "" ]
                                                            • Set Variable [ $_utc_start; Value:Get( CurrentTimeUTCMilliseconds ) ]
                                                            • Set Field [ DEMO::EncodedResult; FmpRichTextJson_Encode ( DEMO::RichTextSource ; "JSON" ; DEMO::PropertiesToEncode ) ]
                                                            • Set Variable [ $_delta; Value:Round( ( Get( CurrentTimeUTCMilliseconds ) - $_utc_start ) / 1000 ; 4 ) ]
                                                            • Set Field [ DEMO::EncodingExecutionTime; $_delta ]
                                                            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: [encode - json]Next Script: [-]
                                                                  Script Nameencode - fmp_calc
                                                                  Run script with full access privilegesOff
                                                                  Include In MenuNo
                                                                  Layouts that use this script
                                                                  Scripts that use this script
                                                                    Script Definition
                                                                    Script Steps
                                                                    • #======================================================================================= Name: encode - fmp_calc Purpose: Translates rich text field content into a FileMaker calculation which can be evaluated to obtain/restore the original rich text. Dependencies: Uses custom function(s) which require a plug-in capable of evaluating a string of JavaScript. Context: ---------------------------------------------------------------- Input Params: (none) Output Values: (none) ---------------------------------------------------------------- Created: 2018-July - steve_ssh Comments: Possible plugins: bBox, BaseElements, MBS. Not tested on Windows. =======================================================================================
                                                                    • Set Field [ DEMO::EncodingExecutionTime[2]; "" ]
                                                                    • Set Field [ DEMO::EncodedResult[2]; "" ]
                                                                    • Set Variable [ $_utc_start; Value:Get( CurrentTimeUTCMilliseconds ) ]
                                                                    • Set Field [ DEMO::EncodedResult[2]; FmpRichTextJson_Encode ( DEMO::RichTextSource ; "FMP_CALC" ; DEMO::PropertiesToEncode ) ]
                                                                    • Set Variable [ $_delta; Value:Round( ( Get( CurrentTimeUTCMilliseconds ) - $_utc_start ) / 1000 ; 4 ) ]
                                                                    • Set Field [ DEMO::EncodingExecutionTime[2]; $_delta ]
                                                                    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: [encode - fmp_calc]Next Script: [decode - json]
                                                                          Script Name-
                                                                          Run script with full access privilegesOff
                                                                          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: [-]Next Script: [decode - fmp_calc]
                                                                                              Script Namedecode - json
                                                                                              Run script with full access privilegesOff
                                                                                              Include In MenuNo
                                                                                              Layouts that use this script
                                                                                              Scripts that use this script
                                                                                                Script Definition
                                                                                                Script Steps
                                                                                                • #======================================================================================= Name: decode - json Purpose: Translates JSON content into the original rich text used to generate the JSON. Dependencies: Uses custom function(s) which require a plug-in capable of evaluating a string of JavaScript. Context: ---------------------------------------------------------------- Input Params: (none) Output Values: (none) ---------------------------------------------------------------- Created: 2018-July - steve_ssh Comments: Possible plugins: bBox, BaseElements, MBS. Not tested on Windows. =======================================================================================
                                                                                                • Set Field [ DEMO::DecodingExecutionTime; "" ]
                                                                                                • Set Field [ DEMO::DecodedResult; "" ]
                                                                                                • Set Variable [ $_utc_start; Value:Get( CurrentTimeUTCMilliseconds ) ]
                                                                                                • Set Variable [ $_fmp_calculation_list; Value:FmpRichTextJson_Decode( DEMO::EncodedResult ; "FMP_CALC" ; "" ) ]
                                                                                                • Perform Script [ “evaluate blocks of fmp calcs”; Parameter: $_fmp_calculation_list ]
                                                                                                • Set Field [ DEMO::DecodedResult; Get( ScriptResult ) ]
                                                                                                • Set Variable [ $_delta; Value:Round( ( Get( CurrentTimeUTCMilliseconds ) - $_utc_start ) / 1000 ; 4 ) ]
                                                                                                • Set Field [ DEMO::DecodingExecutionTime; $_delta ]
                                                                                                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: [decode - json]Next Script: [-]
                                                                                                    Script Namedecode - fmp_calc
                                                                                                    Run script with full access privilegesOff
                                                                                                    Include In MenuNo
                                                                                                    Layouts that use this script
                                                                                                    Scripts that use this script
                                                                                                      Script Definition
                                                                                                      Script Steps
                                                                                                      • #======================================================================================= Name: decode - fmp_calc Purpose: Evaluates FMP calculation code to return the original rich text that generated the calculation code. Dependencies: Uses custom function(s) which require a plug-in capable of evaluating a string of JavaScript. Context: ---------------------------------------------------------------- Input Params: (none) Output Values: (none) ---------------------------------------------------------------- Created: 2018-July - steve_ssh Comments: Possible plugins: bBox, BaseElements, MBS. Not tested on Windows. =======================================================================================
                                                                                                      • Set Field [ DEMO::DecodingExecutionTime[2]; "" ]
                                                                                                      • Set Field [ DEMO::DecodedResult[2]; "" ]
                                                                                                      • Set Variable [ $_utc_start; Value:Get( CurrentTimeUTCMilliseconds ) ]
                                                                                                      • Set Variable [ $_fmp_calculation_list; Value:DEMO::EncodedResult[2] ]
                                                                                                      • Perform Script [ “evaluate blocks of fmp calcs”; Parameter: $_fmp_calculation_list ]
                                                                                                      • Set Field [ DEMO::DecodedResult[2]; Get( ScriptResult ) ]
                                                                                                      • Set Variable [ $_delta; Value:Round( ( Get( CurrentTimeUTCMilliseconds ) - $_utc_start ) / 1000 ; 4 ) ]
                                                                                                      • Set Field [ DEMO::DecodingExecutionTime[2]; $_delta ]
                                                                                                      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: [decode - fmp_calc]Next Script: [evaluate blocks of fmp calcs]
                                                                                                            Script Name-
                                                                                                            Run script with full access privilegesOff
                                                                                                            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: [-]Next Script: [-]
                                                                                                                                Script Nameevaluate blocks of fmp calcs
                                                                                                                                Run script with full access privilegesOff
                                                                                                                                Include In MenuNo
                                                                                                                                Layouts that use this script
                                                                                                                                  Scripts that use this script
                                                                                                                                  Script Definition
                                                                                                                                  Script Steps
                                                                                                                                  • #======================================================================================= Name: evaluate blocks of fmp calcs Purpose: Receives a CR-delimited list of FMP calculation chunks, evaluates each chunk, and concatenates each evaluated result into one long string. Dependencies: Context: ---------------------------------------------------------------- Input Params: A CR-delimited list, where each list item is the text of a FMP calculation. Output Values: The result of evaluating each list item from the input, and then concatenating all of the evaluated results. ---------------------------------------------------------------- Created: 2018-July - steve_ssh Comments: FMP calculations are processed in chunks to avoid exceeding the maximum length of a parameter passed to the Evaluate() function. =======================================================================================
                                                                                                                                  • Set Variable [ $_fmp_calculation_list; Value:Get( ScriptParameter ) ]
                                                                                                                                  • Set Variable [ $_result; Value:"" ]
                                                                                                                                  • Set Variable [ $_i; Value:1 ]
                                                                                                                                  • Set Variable [ $_i_max; Value:ValueCount( $_fmp_calculation_list ) ]
                                                                                                                                  • Loop
                                                                                                                                  • Exit Loop If [ $_i > $_i_max ]
                                                                                                                                  • Set Variable [ $_next_fmp_calc_chunk; Value:GetValue( $_fmp_calculation_list ; $_i ) ]
                                                                                                                                  • Set Variable [ $_result; Value:$_result & Evaluate( $_next_fmp_calc_chunk ) ]
                                                                                                                                  • Set Variable [ $_i; Value:$_i + 1 ]
                                                                                                                                  • End Loop
                                                                                                                                  • Exit Script [ Result: $_result ]
                                                                                                                                  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: [evaluate blocks of fmp calcs]Next Script: [on open]
                                                                                                                                                Script Name-
                                                                                                                                                Run script with full access privilegesOff
                                                                                                                                                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: [-]Next Script: [reset fields]
                                                                                                                                                                    Script Nameon open
                                                                                                                                                                    Run script with full access privilegesOff
                                                                                                                                                                    Include In MenuNo
                                                                                                                                                                    Layouts that use this script
                                                                                                                                                                      Scripts that use this script
                                                                                                                                                                        Script Definition
                                                                                                                                                                        Script Steps
                                                                                                                                                                        • #======================================================================================= Name: on open Purpose: To be run when the solution is first opened. Dependencies: Context: ---------------------------------------------------------------- Input Params: (none) Output Values: (none) ---------------------------------------------------------------- Created: 2018-July - steve_ssh Comments: =======================================================================================
                                                                                                                                                                        • Go to Layout [ “DEMO” ]
                                                                                                                                                                        • If [ Get( ScreenHeight ) > 1040 ]
                                                                                                                                                                        • Adjust Window [ Resize to Fit ]
                                                                                                                                                                        • End If
                                                                                                                                                                        • Show All Records
                                                                                                                                                                        • Go to Record/Request/Page [ First ]
                                                                                                                                                                        • If [ not EvaluateJavascript_ViaAvailablePlugin ( "-enabled" ) ]
                                                                                                                                                                        • New Window [ Style: Card; Using layout: “Plug-In Alert”; Top: 100; Left: ( Get( WindowWidth ) - 465 ) / 2; Close: Yes; Minimize: No; Maximize: No; Resize: No; Menu Bar: No; Dim parent window: Yes; Toolbars: No ]
                                                                                                                                                                        • 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: [on open]Next Script: [set clipboard]
                                                                                                                                                                                  Script Namereset fields
                                                                                                                                                                                  Run script with full access privilegesOff
                                                                                                                                                                                  Include In MenuNo
                                                                                                                                                                                  Layouts that use this script
                                                                                                                                                                                  Scripts that use this script
                                                                                                                                                                                    Script Definition
                                                                                                                                                                                    Script Steps
                                                                                                                                                                                    • #======================================================================================= Name: reset fields Purpose: Clears UI fields. Dependencies: Context: ---------------------------------------------------------------- Input Params: (none) Output Values: (none) ---------------------------------------------------------------- Created: 2018-July - steve_ssh Comments: =======================================================================================
                                                                                                                                                                                    • Set Field [ DEMO::EncodedResult; "" ]
                                                                                                                                                                                    • Set Field [ DEMO::EncodedResult[2]; "" ]
                                                                                                                                                                                    • Set Field [ DEMO::EncodingExecutionTime; "" ]
                                                                                                                                                                                    • Set Field [ DEMO::EncodingExecutionTime[2]; "" ]
                                                                                                                                                                                    • Set Field [ DEMO::DecodedResult; "" ]
                                                                                                                                                                                    • Set Field [ DEMO::DecodedResult[2]; "" ]
                                                                                                                                                                                    • Set Field [ DEMO::DecodingExecutionTime; "" ]
                                                                                                                                                                                    • Set Field [ DEMO::DecodingExecutionTime[2]; "" ]
                                                                                                                                                                                    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: [reset fields]
                                                                                                                                                                                            Script Nameset clipboard
                                                                                                                                                                                            Run script with full access privilegesOff
                                                                                                                                                                                            Include In MenuNo
                                                                                                                                                                                            Layouts that use this script
                                                                                                                                                                                            Scripts that use this script
                                                                                                                                                                                              Script Definition
                                                                                                                                                                                              Script Steps
                                                                                                                                                                                              • #======================================================================================= Name: set clipboard Purpose: Sets the user's clipboard to text passed in as script parameter. Dependencies: Requires that the clipboard field be present on the layout. Context: ---------------------------------------------------------------- Input Params: The text to be set onto the clipboard. Output Values: (none) ---------------------------------------------------------------- Created: 2018-July - steve_ssh Comments: =======================================================================================
                                                                                                                                                                                              • Allow User Abort [ Off ]
                                                                                                                                                                                              • Set Field [ DEMO::ClipboardCopy; Get( ScriptParameter ) ]
                                                                                                                                                                                              • Copy [ DEMO::ClipboardCopy ] [ Select ]
                                                                                                                                                                                              • Set Field [ DEMO::ClipboardCopy; "" ]
                                                                                                                                                                                              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

                                                                                                                                                                                                      Custom Functions

                                                                                                                                                                                                      Function NameParametersAvailabilityDefinitionIn Field DefinitionsIn Scripts
                                                                                                                                                                                                      FmpRichTextJson_EncodeFmpRichText;OutputFormat;IncludeAll accounts/* =================================================================== Function: FmpRichTextJson_Encode( FmpRichText ; OutputFormat ; Include ) Purpose: Translates rich text content into plain-text encoded data which can later be translated back into the original rich text content. Params: - FmpRichText: FileMaker rich text, i.e. text content that may incorporate font, size, or formatting information. - OutputFormat: Supply one of the following two values: "JSON", "FMP_CALC" - Include: Leave empty to encode all rich text properties that this CF can handle. Otherwise, supply a string listing one or more of the following property names: "SIZE", "FONT", "STYLES", "COLOR" Returns: Either JSON, or FileMaker calculation code, depending on the argument supplied for the OutputFormat parameter. Support: Tested with FMPA v.16/17 on MacOS. May run elsewhere, too, though not tested. Requires: Requires CF "EvaluateJavascript", which, in turn, requires MBS plugin. --------------------------------------------------------------------- Comments: - To restore original rich text from JSON output of this function, utilize companion CF "FmpRichTextJson_Decode". - To restore original rich text from FMP calculation output of this function, utilize companion, run the FMP calculation through the native FileMaker command: Evaluate(). - In cases where the rich text content is of large size, it will be necessary to run several iterations of Evaluate, and concatenate the individual results together. - In such a case, the output from this function will not be a single FMP calculation, but rather, a CR-delimited list of FMP calculations, where each list item is to be Evaluated individually. --------------------------------------------------------------------- Credit: - A portion of the following JavaScript library was used to implement HTML-decoding functionality: http://www.strictly-software.com/htmlencode (GPL, The MIT License) --------------------------------------------------------------------- Version: 20180901_1104 Created: July 2018: Initial version. Updates: - Updated 01 Sept 2018: Updated Javascript: Extended special character handling list to include Unicode 8222 and 8223 (variants of quote chars), which (like other quote chars) will break Evaluate(), and thus need special care when serializing to FMP calculation. Thanks to @hhenle for discovering/reporting this issue. Author: https://community.filemaker.com/people/steve_ssh HH comments: - replaced call of CF "EvaluateJavaScript_ViaAvailablePlugin" with "EvaluateJavaScript", i.e. this CF requires MBS plugin - support of all FM text styles added, this was updated by the author after an exchange with the in the FM community =================================================================== */ Case( OutputFormat <> "JS_LIBRARY" ; Let([ /*------- CONSTANTS --------*/ ~MAX_CHARS_PER_FMP_CALCULATION_TEXT = 20 * 1000; // I think this limit is actually larger than 20K -- maybe more like 30K ? ~javascript_lib = FmpRichTextJson_Encode( "" ; "JS_LIBRARY" ; "" ); ~bs = "\\"; ~sq = "'"; // Single quote char /*------- INPUT --------*/ ~input_as_css = GetAsCSS( FmpRichText ); ~inclusions = Include; ~mode = Case( OutputFormat = "JSON"; "text2json" ; OutputFormat = "FMP_CALC" ; "text2fmpcalc" ); /*------- PRE-PROCESSING (quotation for use as JS strings ) --------*/ ~input_css_quoted = ~sq & Substitute( ~input_as_css ; [ ~bs; ~bs & ~bs ]; [ Char( 13 ) ; "\r" ]; [ Char( 10 ) ; "\n" ]; [ Char( 9 ) ; "\t" ]; [ Char( 8232 ) ; "\u2028" ]; [ Char( 8233 ) ; "\u2029" ]; [ ~sq ; ~bs & ~sq ] ) & ~sq; ~inclusions_quoted = ~sq & Substitute( ~inclusions ; [ ~bs; ~bs & ~bs ]; [ Char( 13 ) ; "\r" ]; [ Char( 10 ) ; "\n" ]; [ Char( 9 ) ; "\t" ]; [ Char( 8232 ) ; "\u2028" ]; [ Char( 8233 ) ; "\u2029" ]; [ ~sq ; ~bs & ~sq ] ) & ~sq; ~mode_string =~sq & ~mode & ~sq; /*------- JAVASCRIPT --------*/ /* Ref: function translate( input, mode, inclusions, maxCharsPerFmpCalculation ) */ ~javascript_operation = "translate( " & ~input_css_quoted & ", " & ~mode_string & ", " & ~inclusions_quoted & ", " & ~MAX_CHARS_PER_FMP_CALCULATION_TEXT & " );"; ~javascript_to_execute = List( ~javascript_lib ; ~javascript_operation ) ]; /*------- RESULT --------*/ Case( IsEmpty( ~mode ) ; "ERROR: Invalid OutputFormat parameter supplied. Valid arguments: \"FMP_CALC\", \"JSON\"." ; EvaluateJavascript ( ~javascript_to_execute ) /* Modified CF that only work with MBS plugin */ ) ); /*------- JAVASCRIPT LIBRARIES --------*/ Let([ ~RICH_TEXT_CONVERSION = "¶/* Main point of entry ------------------------------------------------------------------------------------*/ ¶/* ¶ ¶ input and mode params: ¶ ¶ • input = Result of GetAsCSS( someFmpRichText ) --> use mode of text2json to output JSON representation of rich text. ¶ • input = Result of GetAsCSS( someFmpRichText ) --> use mode of text2fmpcalc to output an FMP calculation expression that evaluates back to original rich text. ¶ • input = Rich text JSON from previous call to translate() --> use mode of json2fmpcalc to output an FMP calculation expression that evaluates back to original rich text. ¶ ¶ inclusions: ¶ ¶ • Supply a string containing any of the following to specify which properties to handle/include. Leave empty to include all properties: ¶ ¶ font, size, color, styles ¶ ¶ maxCharsPerFmpCalculation: Indicate the maximum number of allowed characters that can comprise a FMP calculation. ¶ ¶ If FMP calculation output exceeds maximum size, it will be chunked into a CR-delimited list. ¶ Each list entry can be evaluated separately and then all individual results can be concatenated together. ¶ ¶---------------------------------------------------------------------------------------------------------*/ ¶ ¶ ¶function translate( input, mode, inclusions, maxCharsPerFmpCalculation ) { ¶ ¶ if( (/^text2json$/i).test( mode ) ) { ¶ ¶ return getFmpRichTextAsJson( input, inclusions ); ¶ } ¶ else if( (/^text2fmpcalc$/i).test( mode ) ) { ¶ ¶ return getAsFmpCalculation( input, null, inclusions, maxCharsPerFmpCalculation ); ¶ } ¶ else if( (/^json2fmpcalc$/i).test( mode ) ) { ¶ ¶ return getAsFmpCalculation( null, input, inclusions, maxCharsPerFmpCalculation ); ¶ } ¶ else { ¶ ¶ return 'ERROR: Unrecognized/invalid mode parameter: [' + mode + ']'; ¶ } ¶} ¶ ¶ ¶ ¶/* Translates the result of GetAsCSS( inputValue ) to JSON describing inputValue as rich text. */ ¶ ¶function getFmpRichTextAsJson( fmpCssString, inclusions ) { ¶ ¶ var segmentArray = getFmpRichTextAsSegmentArray( fmpCssString, inclusions ); ¶ ¶ var result = JSON.stringify( segmentArray, null, ' ' ); ¶ ¶ /* Additional substitutions to prevent some systems from breaking when reading JSON: Line Separator, Paragraph Separator, Left Curly Quotes, Right Curly Quotes */ ¶ ¶ return result.replace( /\u2028/g, '\\\u2028' ).replace( /\u2029/g, '\\\u2029' ).replace( /\u201c/g, '\\\u201c' ).replace( /\u201d/g, '\\\u201d' ); ¶ ¶} ¶ ¶ ¶/* Translates the input to a FileMaker calculation which can be evaluated to restore inputValue as rich text. */ ¶/* Supply only one of: fmpCssString or richTextJson */ ¶ ¶function getAsFmpCalculation( fmpCssString, richTextJson, inclusions, maxCharsPerFmpCalculation ) { ¶ ¶ try { ¶ ¶ var segmentArray = ( fmpCssString ) ? getFmpRichTextAsSegmentArray( fmpCssString ) : parseJsonToSegmentArray( richTextJson ); ¶ ¶ var calculationArray = segmentArray.map( translateSegmentToFmpCalculationChunk, getInclusions( inclusions ) ); ¶ ¶ return joinCalculationArray( calculationArray, maxCharsPerFmpCalculation ); ¶ ¶ } ¶ catch( err ) { ¶ ¶ return 'ERROR: ' + err; ¶ } ¶} ¶ ¶/* Basic validation and parsing of a string of JSON into an array of objects representing text segments. */ ¶ ¶function parseJsonToSegmentArray( richTextJson ) { ¶ ¶ if( typeof richTextJson != 'string' || !(/^\s*\[/).test( richTextJson ) || !(/\]\s*$/).test( richTextJson ) ) { ¶ ¶ throw 'Input does not appear to be a JSON array.'; ¶ } ¶ ¶ try{ ¶ ¶ return JSON.parse( richTextJson ); ¶ } ¶ catch( parseErr ) { ¶ ¶ throw 'JSON parse error: ' + parseErr; ¶ } ¶} ¶ ¶ ¶/* Joins FMP calculation segments into a single long FMP calculation string. */ ¶/* Inserts returns to delimit final calculation into blocks which are small enough for FMP calculation engine to evaluate. */ ¶ ¶function joinCalculationArray( calculationArray, maxCharsPerFmpCalculation ) { ¶ ¶ maxCharsPerFmpCalculation = maxCharsPerFmpCalculation || 20000; ¶ ¶ var calculationString = ''; ¶ ¶ var currentBlockLength = 0; ¶ ¶ var concatentationString = ' & '; ¶ ¶ calculationArray.forEach( function( nextCalculationChunk ) { ¶ ¶ var appendString = ( calculationString.length ) ? concatentationString: ''; ¶ ¶ appendString += nextCalculationChunk; ¶ ¶ if( currentBlockLength + appendString.length > maxCharsPerFmpCalculation ) { ¶ ¶ /* When starting a new block, we don't include concatenation string. */ ¶ /* It will only get in the way when processing each block separately. */ ¶ ¶ calculationString += '\r' + nextCalculationChunk; ¶ ¶ currentBlockLength = nextCalculationChunk.length; ¶ } ¶ else { ¶ ¶ calculationString += appendString; ¶ ¶ currentBlockLength += appendString.length; ¶ } ¶ }); ¶ ¶ return calculationString; ¶} ¶ ¶ ¶/* Returns an array of POJOs, each of which describes a \"segment\" of the CSS string. */ ¶/* A segment is a block of text contained by a single html <span> element. */ ¶ ¶function getFmpRichTextAsSegmentArray( fmpCssString, inclusions ) { ¶ ¶ var inputArray = ( fmpCssString || '' ).split( '</span>' ); ¶ ¶ inputArray.pop(); /* Splitting on </span> will generate an unwanted final array entry of an empty string; we remove it. */ ¶ ¶ return inputArray.map( convertSegmentStringtoPOJO, getInclusions( inclusions ) ); ¶} ¶ ¶/* Translates the supplied inclusion string into an object format. */ ¶ ¶function getInclusions( inclusions ) { ¶ ¶ inclusions = inclusions || 'color font size styles'; ¶ ¶ return { ¶ ¶ color: (/color/i).test( inclusions ), ¶ ¶ font: (/font/i).test( inclusions ), ¶ ¶ fontSize: (/size/i).test( inclusions ), ¶ ¶ styles: (/styles/i).test( inclusions ) ¶ }; ¶ ¶} ¶ ¶/* Translates a text segment encapsulated by a <span> element into an object representation. */ ¶ ¶function convertSegmentStringtoPOJO( segmentString ) { ¶ ¶ var segmentData = segmentString.replace( /\<br\/\>/g, '\r' ).split( '>' ); ¶ ¶ var formatString = segmentData[ 0 ]; ¶ ¶ var dataEscaped = segmentData[ 1 ]; ¶ ¶ var result = { data: undoHtmlMarkup( dataEscaped ) }; ¶ ¶ /* The 'this' object has been set to the 'inclusions' object, which tells us which properties to include. */ ¶ ¶ if( this.color ) { ¶ ¶ result.color = parseColor( formatString ); ¶ } ¶ if( this.font ) { ¶ ¶ result.font = parseFont( formatString ); ¶ } ¶ if( this.fontSize ) { ¶ ¶ result.fontSize = parseFontSize( formatString ); ¶ } ¶ if( this.styles ) { ¶ ¶ result.styles = parseStyles( formatString ); ¶ } ¶ ¶ return result; ¶} ¶ ¶function parseColor( formatString ) { ¶ ¶ var color = (/[^-]color\: \#([^\;]+)\;/).exec( formatString ) || [ '', '' ]; ¶ ¶ var colorHex = color[1]; ¶ ¶ return colorHex ? { hex: colorHex, rgb: rgbFromHex( colorHex ) }: null; ¶} ¶ ¶function parseFont( formatString ) { ¶ ¶ var fontMatch = (/font-family\: \'([^\']+)\'\;/).exec( formatString ) || [ '', '' ]; ¶ ¶ return fontMatch[1]; ¶} ¶ ¶function parseFontSize( formatString ) { ¶ ¶ var fontSizeMatch = (/font-size\: ([0-9]+)px/).exec( formatString ) || [ '', '' ]; ¶ ¶ return fontSizeMatch[1]; ¶} ¶ ¶function parseStyles( formatString ) { ¶ ¶ var styleMatchers = getFmpStyleMatchers(); ¶ ¶ styles = {}; ¶ ¶ for( var style in styleMatchers ) { ¶ ¶ styles[ style ] = styleMatchers[ style ].test( formatString ) ? true: false; ¶ } ¶ ¶ return styles; ¶} ¶ ¶function undoHtmlMarkup( markedUpData ) { /* Uses third-party code to perform html decoding. */ ¶ ¶ return Encoder.htmlDecode( markedUpData ); ¶} ¶ ¶function rgbFromHex( colorHex6Digits ) { ¶ ¶ var rgb = {}; ¶ ¶ rgb.R = parseInt( colorHex6Digits.substring( 0, 2 ), 16 ); ¶ ¶ rgb.G = parseInt( colorHex6Digits.substring( 2, 4 ), 16 ); ¶ ¶ rgb.B = parseInt( colorHex6Digits.substring( 4, 6 ), 16 ); ¶ ¶ return rgb; ¶} ¶ ¶/* Translates an object representation of a chunk of text into a FileMaker calculation, which can be evaluated to restore original rich text. */ ¶ ¶function translateSegmentToFmpCalculationChunk( segmentObject ) { ¶ ¶ if( typeof segmentObject != 'object' ) { ¶ ¶ throw 'Unexpected data-type [' + typeof segmentObject + '] encountered while attempting to read segment.'; ¶ } ¶ ¶ var outputCalc = prepTextForFmpCalculation( segmentObject.data ); ¶ ¶ /* The 'this' object has been set to the 'inclusions' object, which tells us which properties to include. */ ¶ ¶ if( this.font ) { ¶ ¶ outputCalc = segmentObject.font ? addFontToFmpCalc( outputCalc, segmentObject.font ): outputCalc; ¶ } ¶ if( this.color ) { ¶ ¶ outputCalc = segmentObject.color ? addColorToFmpCalc( outputCalc, segmentObject.color ) : outputCalc; ¶ } ¶ if( this.fontSize ) { ¶ ¶ var fontSize = segmentObject.fontSize; ¶ ¶ var fontSizeHasBeenHalvedForStyle = segmentObject.styles && ( segmentObject.styles.Superscript || segmentObject.styles.Subscript ); /* Superscript and Subscript result in the font-size being written to CSS as half of the original FMP rich text size */ ¶ ¶ /* We restore the original fontsize for FMP use. Note that, due to rounding in GetAsCSS, this restored value could be off by 1 pt (too large) if the original rich text font size was an odd-numbered value. */ ¶ ¶ fontSize = fontSizeHasBeenHalvedForStyle ? ( 2 * fontSize ): fontSize; ¶ ¶ outputCalc = segmentObject.fontSize ? addSizeToFmpCalc( outputCalc, fontSize ) : outputCalc; ¶ } ¶ if( this.styles ) { ¶ ¶ outputCalc = segmentObject.styles ? addStylesToFmpCalc( outputCalc, segmentObject.styles ) : outputCalc; ¶ } ¶ ¶ return outputCalc; ¶} ¶ ¶function prepTextForFmpCalculation( text ) { ¶ ¶ var result = fmpQuote( text || '' ); ¶ ¶ result = translatePilcrows( result ); ¶ ¶ result = translateTabsAndNewlinesAndOtherCharsThatWouldBreakFmpCalculations( result ); ¶ ¶ return result; ¶} ¶ ¶function translatePilcrows( text ) { ¶ ¶ /* Pilcrow char (¶) is CodePoint 182. */ ¶ /* Could probably hardcode the char directly, i.e. /\\¶/g, but choosing not to do so, just out of conservative paranoia. */ ¶ ¶ var pilcrowRegex = new RegExp( '\\\' + String.fromCharCode( 182 ), 'g' ); ¶ ¶ return text.replace( pilcrowRegex, '\" & Char(182) & \"' ); ¶} ¶ ¶function translateTabsAndNewlinesAndOtherCharsThatWouldBreakFmpCalculations( text ) { ¶ ¶ var result = text; ¶ ¶ var codePointsToReplace = [ 13, 10, 9, 8232, 2833, 8220, 8221, 8222, 8223 ]; ¶ ¶ codePointsToReplace.forEach( function( codepoint ) { ¶ ¶ var regexp = new RegExp( String.fromCharCode( codepoint ), 'g' ); ¶ ¶ var replacementString = '\" & Char( ' + codepoint + ' ) & \"' ; ¶ ¶ result = result.replace( regexp, replacementString ); ¶ }); ¶ ¶ return result; ¶} ¶ ¶function fmpQuote( text ) { ¶ ¶ return '\"' + backslashAndDoubleQuoteEscape( text ) + '\"'; ¶} ¶ ¶function backslashAndDoubleQuoteEscape( text ) { ¶ ¶ return text.replace( /\\\/g, '\\\\\\\' ).replace( /\\\"/g, '\\\\\"' ); ¶} ¶ ¶function addColorToFmpCalc( calculationChunk, color ) { ¶ ¶ return 'TextColor(' + calculationChunk + '; RGB(' + color.rgb.R + ';' + color.rgb.G + ';' + color.rgb.B + '))'; ¶} ¶ ¶function addFontToFmpCalc( calculationChunk, font ) { ¶ ¶ return 'TextFont(' + calculationChunk + '; ' + fmpQuote( font ) + ')'; ¶} ¶ ¶function addSizeToFmpCalc( calculationChunk, fontSize ) { ¶ ¶ return 'TextSize(' + calculationChunk + '; ' + fontSize + ')'; ¶} ¶ ¶function addStylesToFmpCalc( calculationChunk, styles ) { ¶ ¶ var result = calculationChunk; ¶ ¶ var styleMatchers = getFmpStyleMatchers(); ¶ ¶ for( var style in styleMatchers ) { ¶ ¶ if( styles[ style ] ) { ¶ ¶ result = 'TextStyleAdd(' + result + '; ' + style + ')'; ¶ } ¶ } ¶ ¶ return result; ¶} ¶ ¶function getFmpStyleMatchers() { ¶ ¶ return { ¶ ¶ Bold: /font-weight\: bold\;/, ¶ ¶ Italic: /font-style\:italic\;/, ¶ ¶ Underline: /text-decoration\:underline/, ¶ ¶ StrikeThrough: /text-decoration\:line-through/, ¶ ¶ HighlightYellow: /background-color\: \#FFFF00/, ¶ ¶ Condense: /letter-spacing\: -2px/, ¶ ¶ Extend: /letter-spacing\: 2px/, ¶ ¶ SmallCaps: /font-variant\:small-caps/, ¶ ¶ Uppercase: /text-transform\: uppercase/, ¶ ¶ Lowercase: /text-transform\: lowercase/, ¶ ¶ Titlecase: /text-transform\: capitalize/, ¶ ¶ Superscript: /vertical-align\: text-top/, ¶ ¶ Subscript: /vertical-align\: text-bottom/ ¶ ¶ }; ¶}"; ~HTML_DECODING_LIBRARY = /* The following taken from: https://gist.github.com/ajinabraham/1af8216dfb6f959503e0#file-encoder-js */ "¶ ¶/** ¶ * A Javascript object to encode and/or decode html characters using HTML or Numeric entities that handles double or partial encoding ¶ * Author: R Reid ¶ * source: http://www.strictly-software.com/htmlencode ¶ * Licences: GPL, The MIT License (MIT) ¶ * Copyright: (c) 2011 Robert Reid - Strictly-Software.com ¶ * ¶ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"¶), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: ¶ * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. ¶ * THE SOFTWARE IS PROVIDED \"AS IS\" ¶, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ¶ * ¶ * Revision: ¶ * 2011-07-14, Jacques-Yves Bleau: ¶ * - fixed conversion error with capitalized accentuated characters ¶ * + converted arr1 and arr2 to object property to remove redundancy ¶ * ¶ * Revision: ¶ * 2011-11-10, Ce-Yi Hio: ¶ * - fixed conversion error with a number of capitalized entity characters ¶ * ¶ * Revision: ¶ * 2011-11-10, Rob Reid: ¶ * - changed array format ¶ * ¶ * Revision: ¶ * 2012-09-23, Alex Oss: ¶ * - replaced string concatonation in numEncode with string builder, push and join for peformance with ammendments by Rob Reid ¶ */ ¶ ¶Encoder = { ¶ ¶ isEmpty : function(val){ ¶ if(val){ ¶ return ((val===null) || val.length==0 || /^\s+$/.test(val)); ¶ }else{ ¶ return true; ¶ } ¶ }, ¶ ¶ /* arrays for conversion from HTML Entities to Numerical values */ ¶ arr1: ['&nbsp;','&iexcl;','&cent;','&pound;','&curren;','&yen;','&brvbar;','&sect;','&uml;','&copy;','&ordf;','&laquo;','&not;','&shy;','&reg;','&macr;','&deg;','&plusmn;','&sup2;','&sup3;','&acute;','&micro;','&para;','&middot;','&cedil;','&sup1;','&ordm;','&raquo;','&frac14;','&frac12;','&frac34;','&iquest;','&Agrave;','&Aacute;','&Acirc;','&Atilde;','&Auml;','&Aring;','&AElig;','&Ccedil;','&Egrave;','&Eacute;','&Ecirc;','&Euml;','&Igrave;','&Iacute;','&Icirc;','&Iuml;','&ETH;','&Ntilde;','&Ograve;','&Oacute;','&Ocirc;','&Otilde;','&Ouml;','&times;','&Oslash;','&Ugrave;','&Uacute;','&Ucirc;','&Uuml;','&Yacute;','&THORN;','&szlig;','&agrave;','&aacute;','&acirc;','&atilde;','&auml;','&aring;','&aelig;','&ccedil;','&egrave;','&eacute;','&ecirc;','&euml;','&igrave;','&iacute;','&icirc;','&iuml;','&eth;','&ntilde;','&ograve;','&oacute;','&ocirc;','&otilde;','&ouml;','&divide;','&oslash;','&ugrave;','&uacute;','&ucirc;','&uuml;','&yacute;','&thorn;','&yuml;','&quot;','&amp;','&lt;','&gt;','&OElig;','&oelig;','&Scaron;','&scaron;','&Yuml;','&circ;','&tilde;','&ensp;','&emsp;','&thinsp;','&zwnj;','&zwj;','&lrm;','&rlm;','&ndash;','&mdash;','&lsquo;','&rsquo;','&sbquo;','&ldquo;','&rdquo;','&bdquo;','&dagger;','&Dagger;','&permil;','&lsaquo;','&rsaquo;','&euro;','&fnof;','&Alpha;','&Beta;','&Gamma;','&Delta;','&Epsilon;','&Zeta;','&Eta;','&Theta;','&Iota;','&Kappa;','&Lambda;','&Mu;','&Nu;','&Xi;','&Omicron;','&Pi;','&Rho;','&Sigma;','&Tau;','&Upsilon;','&Phi;','&Chi;','&Psi;','&Omega;','&alpha;','&beta;','&gamma;','&delta;','&epsilon;','&zeta;','&eta;','&theta;','&iota;','&kappa;','&lambda;','&mu;','&nu;','&xi;','&omicron;','&pi;','&rho;','&sigmaf;','&sigma;','&tau;','&upsilon;','&phi;','&chi;','&psi;','&omega;','&thetasym;','&upsih;','&piv;','&bull;','&hellip;','&prime;','&Prime;','&oline;','&frasl;','&weierp;','&image;','&real;','&trade;','&alefsym;','&larr;','&uarr;','&rarr;','&darr;','&harr;','&crarr;','&lArr;','&uArr;','&rArr;','&dArr;','&hArr;','&forall;','&part;','&exist;','&empty;','&nabla;','&isin;','&notin;','&ni;','&prod;','&sum;','&minus;','&lowast;','&radic;','&prop;','&infin;','&ang;','&and;','&or;','&cap;','&cup;','&int;','&there4;','&sim;','&cong;','&asymp;','&ne;','&equiv;','&le;','&ge;','&sub;','&sup;','&nsub;','&sube;','&supe;','&oplus;','&otimes;','&perp;','&sdot;','&lceil;','&rceil;','&lfloor;','&rfloor;','&lang;','&rang;','&loz;','&spades;','&clubs;','&hearts;','&diams;'], ¶ arr2: ['&#160;','&#161;','&#162;','&#163;','&#164;','&#165;','&#166;','&#167;','&#168;','&#169;','&#170;','&#171;','&#172;','&#173;','&#174;','&#175;','&#176;','&#177;','&#178;','&#179;','&#180;','&#181;','&#182;','&#183;','&#184;','&#185;','&#186;','&#187;','&#188;','&#189;','&#190;','&#191;','&#192;','&#193;','&#194;','&#195;','&#196;','&#197;','&#198;','&#199;','&#200;','&#201;','&#202;','&#203;','&#204;','&#205;','&#206;','&#207;','&#208;','&#209;','&#210;','&#211;','&#212;','&#213;','&#214;','&#215;','&#216;','&#217;','&#218;','&#219;','&#220;','&#221;','&#222;','&#223;','&#224;','&#225;','&#226;','&#227;','&#228;','&#229;','&#230;','&#231;','&#232;','&#233;','&#234;','&#235;','&#236;','&#237;','&#238;','&#239;','&#240;','&#241;','&#242;','&#243;','&#244;','&#245;','&#246;','&#247;','&#248;','&#249;','&#250;','&#251;','&#252;','&#253;','&#254;','&#255;','&#34;','&#38;','&#60;','&#62;','&#338;','&#339;','&#352;','&#353;','&#376;','&#710;','&#732;','&#8194;','&#8195;','&#8201;','&#8204;','&#8205;','&#8206;','&#8207;','&#8211;','&#8212;','&#8216;','&#8217;','&#8218;','&#8220;','&#8221;','&#8222;','&#8224;','&#8225;','&#8240;','&#8249;','&#8250;','&#8364;','&#402;','&#913;','&#914;','&#915;','&#916;','&#917;','&#918;','&#919;','&#920;','&#921;','&#922;','&#923;','&#924;','&#925;','&#926;','&#927;','&#928;','&#929;','&#931;','&#932;','&#933;','&#934;','&#935;','&#936;','&#937;','&#945;','&#946;','&#947;','&#948;','&#949;','&#950;','&#951;','&#952;','&#953;','&#954;','&#955;','&#956;','&#957;','&#958;','&#959;','&#960;','&#961;','&#962;','&#963;','&#964;','&#965;','&#966;','&#967;','&#968;','&#969;','&#977;','&#978;','&#982;','&#8226;','&#8230;','&#8242;','&#8243;','&#8254;','&#8260;','&#8472;','&#8465;','&#8476;','&#8482;','&#8501;','&#8592;','&#8593;','&#8594;','&#8595;','&#8596;','&#8629;','&#8656;','&#8657;','&#8658;','&#8659;','&#8660;','&#8704;','&#8706;','&#8707;','&#8709;','&#8711;','&#8712;','&#8713;','&#8715;','&#8719;','&#8721;','&#8722;','&#8727;','&#8730;','&#8733;','&#8734;','&#8736;','&#8743;','&#8744;','&#8745;','&#8746;','&#8747;','&#8756;','&#8764;','&#8773;','&#8776;','&#8800;','&#8801;','&#8804;','&#8805;','&#8834;','&#8835;','&#8836;','&#8838;','&#8839;','&#8853;','&#8855;','&#8869;','&#8901;','&#8968;','&#8969;','&#8970;','&#8971;','&#9001;','&#9002;','&#9674;','&#9824;','&#9827;','&#9829;','&#9830;'], ¶ ¶ /* Convert HTML entities into numerical entities */ ¶ HTML2Numerical : function(s){ ¶ return this.swapArrayVals(s,this.arr1,this.arr2); ¶ }, ¶ ¶ ¶ /* HTML Decode numerical and HTML entities back to original values */ ¶ htmlDecode : function(s){ ¶ ¶ var c,m,d = s; ¶ ¶ /* if(this.isEmpty(d)) return \"\"; modified this line to accommodate input which contains only significant whitespace, e.g. return chars. -ssh 2080710 */ ¶ if(this.isEmpty(d)) return d; ¶ ¶ /* convert HTML entites back to numerical entites first */ ¶ d = this.HTML2Numerical(d); ¶ ¶ /* look for numerical entities &#34; */ ¶ arr=d.match(/&#[0-9]{1,5};/g); ¶ ¶ /* if no matches found in string then skip */ ¶ if(arr!=null){ ¶ for(var x=0;x<arr.length;x++){ ¶ m = arr[x]; ¶ c = m.substring(2,m.length-1); /* get numeric part which is refernce to unicode character */ ¶ /* if its a valid number we can decode */ ¶ if(c >= -32768 && c <= 65535){ ¶ /* decode every single match within string */ ¶ d = d.replace(m, String.fromCharCode(c)); ¶ }else{ ¶ d = d.replace(m, \"\"); /* invalid so replace with nada */ ¶ } ¶ } ¶ } ¶ ¶ return d; ¶ }, ¶ ¶ ¶ /* Function to loop through an array swaping each item with the value from another array e.g swap HTML entities with Numericals */ ¶ swapArrayVals : function(s,arr1,arr2){ ¶ if(this.isEmpty(s)) return \"\"; ¶ var re; ¶ if(arr1 && arr2){ ¶ /* array lengths must match */ ¶ if(arr1.length == arr2.length){ ¶ for(var x=0,i=arr1.length;x<i;x++){ ¶ re = new RegExp(arr1[x], 'g'); ¶ s = s.replace(re,arr2[x]); /* swap arr1 item with matching item from arr2 */ ¶ } ¶ } ¶ } ¶ return s; ¶ } ¶ ¶};" ]; List( ~HTML_DECODING_LIBRARY ; ~RICH_TEXT_CONVERSION ) ) )
                                                                                                                                                                                                        FmpRichTextJson_DecodeJson;OutputFormat;IncludeAll accounts/* =================================================================== Function: FmpRichTextJson_Decode( Json ; OutputFormat ; Include ) Purpose: Translates JSON output from CF, FmpRichTextJson_Encode, back into the original rich text content. Params: - Json: Translates JSON output from CF, FmpRichTextJson_Encode. - OutputFormat: Supply one of the following two values: "RICH_TEXT", "FMP_CALC" - Include: Leave empty to encode all rich text properties that this CF can handle. Otherwise, supply a string listing one or more of the following property names: "SIZE", "FONT", "STYLES", "COLOR" Returns: Either the rich text content originally supplied to CF, FmpRichTextJson_Encode, or FileMaker calculation code, depending on the argument supplied for the OutputFormat parameter. Support: Tested with FMPA v.16/17 on MacOS. May run elsewhere, too, though not tested. Requires: Requires CF, "EvaluateJavascript_ViaAvailablePlugin", which, in turn, requires an enabled plugin which is capable of evaluating JavaScript, e.g. bBox, BaseElements, MBS. --------------------------------------------------------------------- Comments: - In cases where the rich text content is of large size, setting OutputFormat parameter to "RICH_TEXT" will result in an error. - In such cases, it will be necessary to use an OutputFormat parameter of "FMP_CALC". This will return a CR-delimited list of FMP calculations. - It will be necessary to process each list item with the native FileMaker function, Evaluate(), and then concatenate the individual results together. --------------------------------------------------------------------- Version: 20180712_2300 Created: July 2018: Initial version. Updates: Author: https://community.filemaker.com/people/steve_ssh HH comments: - replaced call of CF "EvaluateJavaScript_ViaAvailablePlugin" with "EvaluateJavaScript", i.e. this CF requires MBS plugin =================================================================== */ Let([ /*------- CONSTANTS --------*/ ~MAX_CHARS_PER_FMP_CALCULATION_TEXT = 20 * 1000; // I think this limit is actually larger than 20K -- maybe more like 30K ? ~javascript_lib = FmpRichTextJson_Encode( "" ; "JS_LIBRARY" ; "" ); ~bs = "\\"; ~sq = "'"; // Single quote char /*------- INPUT --------*/ ~input = Json; ~inclusions = Include; ~mode = "json2fmpcalc"; ~output_format = Case( OutputFormat = "RICH_TEXT" ; "RICH_TEXT" ; OutputFormat = "FMP_CALC" ; "FMP_CALC" ); /*------- PRE-PROCESSING (quotation for use as JS strings ) --------*/ ~input_quoted = ~sq & Substitute( ~input ; [ ~bs; ~bs & ~bs ]; [ Char( 13 ) ; "\r" ]; [ Char( 10 ) ; "\n" ]; [ Char( 9 ) ; "\t" ]; [ Char( 8232 ) ; "\u2028" ]; [ Char( 8233 ) ; "\u2029" ]; [ ~sq ; ~bs & ~sq ] ) & ~sq; ~inclusions_quoted = ~sq & Substitute( ~inclusions ; [ ~bs; ~bs & ~bs ]; [ Char( 13 ) ; "\r" ]; [ Char( 10 ) ; "\n" ]; [ Char( 9 ) ; "\t" ]; [ Char( 8232 ) ; "\u2028" ]; [ Char( 8233 ) ; "\u2029" ]; [ ~sq ; ~bs & ~sq ] ) & ~sq; ~mode_string =~sq & ~mode & ~sq; /*------- JAVASCRIPT --------*/ /* function translate( input, mode, inclusions, maxCharsPerFmpCalculation ) */ ~javascript_operation = "translate( " & ~input_quoted & ", " & ~mode_string & ", " & ~inclusions_quoted & ", " & ~MAX_CHARS_PER_FMP_CALCULATION_TEXT & " );"; ~javascript_to_execute = List( ~javascript_lib ; ~javascript_operation ); /*------- FMP CALCULATION --------*/ ~fmp_calculation = EvaluateJavascript( ~javascript_to_execute ) /* Modified CF working with MBS plugin only */ ]; /*------- RESULT --------*/ Case( IsEmpty( ~output_format ) ; "ERROR: Invalid OutputFormat parameter supplied. Valid arguments: \"FMP_CALC\", \"RICH_TEXT\"." ; ~output_format = "FMP_CALC" ; ~fmp_calculation ; Position( ~fmp_calculation ; Char( 13 ) ; 0 ; 1 ) > 0 ; "ERROR: Text is too long to convert \"RICH_TEXT\" output format. Instead please use \"FMP_CALC\" output format, and iterate over returned CR-delimited values."; Evaluate( ~fmp_calculation ) ) )
                                                                                                                                                                                                          EvaluateJavascript_ViaAvailablePluginJavascriptSourceAll accounts/* =================================================================== Function: EvaluateJavascript_ViaAvailablePlugin( JavsScriptSource ) Purpose: Evaluates supplied JavaScript source, and returns the result. Requires an available plug-in which can perform JavaScript evaluations. Params: - JavsScriptSource: JavaScript source code. Alternatively, supply one of the following parameters to return information about the plug-in being used: "-version" : Returns the name and version of the plug-in which will be used to evaluate JavaScript. "-enabled" : Returns a boolean value indicating whether or not a supported plug-in was detected. Returns: The evaluation result, as returned by the plug-in, including any possible error messages. Returns an error message if no supported JavaScript-capable plug-in is available. Support: Tested with FMPA v.16/17 on MacOS. May run elsewhere, too, though not tested. Requires: Requires an installed/enabled version of one of the following supported JavaScript -capable plug-ins: bBox, BaseElements, MBS. --------------------------------------------------------------------- Comments: - Utilizes Evaluate() in order to invoke the plugin functions, so as to allow the custom function to be pasted into a solution without error, even if none of the supported plug-ins are available at the time that the CF is added to the solution. Credit: - Many thanks to the authors of FileMaker plug-ins which support JavaScript evaluation (among many other great features). Your work is highly appreciated both by myself, and the FileMaker community. --------------------------------------------------------------------- Version: 20180712_2300 Created: July 2018: Initial version. Updates: Author: https://community.filemaker.com/people/steve_ssh =================================================================== */ Let([ ~ERROR_MESSAGE = "No recogized JavaScript plugin available."; ~input = JavascriptSource ; /* ===== Determine plug-in availability ===== */ ~available_plugin = Case( EvaluationError( Evaluate( "bBox_Version" ) ) = 0 and Evaluate( "bBox_Version" ) <> "0.88" ; "bBox" ; /* Possible issue with v0.88 of bBox, in cases where invalid JavaScript input is supplied. */ EvaluationError( Evaluate( "BE_Version" ) ) = 0; "BaseElements" ; Get( SystemPlatform ) = 1 and EvaluationError( Evaluate( "MBS(\"Version\")" ) ) = 0; "MBS" ; /* Get( SystemPlatform ) = 1 ==> MacOS */ ); ~enabled = not IsEmpty( ~available_plugin ) ]; Case( /* ===== Handle informative cases ===== */ ~input = "-enabled" ; ~enabled ; not ~enabled ; ~ERROR_MESSAGE ; ~input = "-version" ; ~available_plugin & ": " & Case( ~available_plugin = "bBox" ; Evaluate( "bBox_Version" ) ; ~available_plugin = "BaseElements" ; Evaluate( "BE_Version" ) ; ~available_plugin = "MBS" ; Evaluate( "MBS(\"Version\")" ) ); /* ===== Handle JavaScript processing cases ===== */ Let([ $jsSource_ExecuteJavascript_ViaPlugin = ~input; /* This variable will be available during the Evaluate() calls used to invoke the plugins' Javascript functionality. */ ~js_result = Case( ~available_plugin = "bBox" ; Evaluate( "bBox_JavaScript( $jsSource_ExecuteJavascript_ViaPlugin )" ) ; ~available_plugin = "BaseElements" ; Evaluate( "BE_EvaluateJavaScript( $jsSource_ExecuteJavascript_ViaPlugin )" ) ; ~available_plugin = "MBS" ; Evaluate( "Let([ ~mbs_js_context = MBS( \"JavaScript.New\" ); ~mbs_js_result = MBS( \"JavaScript.EvaluateScript\"; ~mbs_js_context ; $jsSource_ExecuteJavascript_ViaPlugin ); ~release = MBS( \"JavaScript.Release\"; ~mbs_js_context ) ] ; ~mbs_js_result )" ) ); $jsSource_ExecuteJavascript_ViaPlugin = "" /* Clean up this variable before exiting. */ ]; Case( ~available_plugin = "MBS" and Code( Right( ~js_result ; 1 ) ) = 0 ; Left( ~js_result; Length( ~js_result ) - 1 ) ; /* MBS JavaScript output can be a null-terminated string */ ~js_result ) ) // End Let for executing JS ) // End result Case statement ) // End main Let
                                                                                                                                                                                                            _All accounts
                                                                                                                                                                                                              EvaluateJavascriptJavascriptSourceAll accounts/* =================================================================== Function: EvaluateJavascript( JavsScriptSource ) Purpose: Evaluates supplied JavaScript source, and returns the result. Params: JavsScriptSource: JavaScript source code. Requires: MBS - Plugin Notes: This is a stripped down version of the original CF by steve_ssh that specifically requires the MBS plugin ---------------------------------------------------------------------*/ Let( [ ~input = JavaScriptSource; // Evaluate JavaScript with MBS plugin ~js_context = MBS( "JS.New" ); ~js_result = MBS( "JS.EvaluateToString"; ~js_context ; ~input ); ~release = MBS( "JS.Free"; ~js_context ) ]; // MBS JavaScript output can be a null-terminated string Case( Code( Right( ~js_result ; 1 ) ) = 0 ; Left( ~js_result; Length( ~js_result ) - 1 ) ; ~js_result ) )

                                                                                                                                                                                                                Custom Menu Sets

                                                                                                                                                                                                                Menu SetsMenusIn ScriptsIn LayoutsComments
                                                                                                                                                                                                                [Standard FileMaker Menus]
                                                                                                                                                                                                                • All Standard Menus

                                                                                                                                                                                                                Download example: RichTextToJSON

                                                                                                                                                                                                                Used functions: