Parse XML Script Parameters

Version 2

     

    Script

     

    Compatibility
    Creator
    Mac OS X, Windows
    Todd Duell
    FMP 9, 10, 11
    Formulations Pro
    Web: No
    File Type: FP7
    Server: Yes
    FileSize: ~ .7 megabytes
    http://www.formulationspro.com

    Description

    Sending data to scripts using script parameters and script variables is an extremely powerful technique that every developer, whether a beginner or expert, should know how to do. It enables you to create dynamic scripts that can be reused throughout your entire solution. Up until now there have been two main techniques to send data to a script. The first is to separate your data between some type of marker, such as the pipe character "|", which requires exact parsing to obtain your data. The second is to send your data on separate lines and parse the contents with the MiddleValues function. This is a much easier technique. The problem with both of these approaches is that your data must be in an exact order for your script to parse it correctly. Using a simple custom function, with the old-school FileMaker Middle and Position functions, you can create a dynamic XML-like parsing function that allows you to specify your data in any order.

     


    Code

     

    Sample Input

    Sample Output


    Developer's Notes

    See sample file for full demo and technical article.

     


    FileMaker Inc. provides this content on an “As Is” basis, without any warranty, and subject to the terms of the FileMaker Technical Network Agreement. FileMaker makes no representations and is not liable for any content or related information. You may use the content as part of your own solutions and for your customers, but you may not otherwise publicly distribute any content that you did not submit. ©2009-2011 FileMaker, Inc. All Rights Reserved. FileMaker is a trademark of FileMaker, Inc. registered in the U.S. and other countries.