ParamConverter

by Donovan Chandler

Overview

As outlined here, ModularFileMaker.org suggests using “Let Variables” for passing named parameters to scripts. This method for constructing name-value pairs is popular in large part because it leverages native functionality and doesn’t require any custom functions.

//-- Let Format --
"$name = \"Calvin\" ;
$age = 5 ;"

Still, others prefer to use alternative dictionary formats. One such format is the one created and popularized by Jesse Antunes of Six Fried Rice. (Let’s call it SFR format.)

//-- SFR Format --
"<:name:=Calvin:>
<:age:=5:>"

This module provides a means for systems employing SFR format to easily integrate Let-based modules with minimal effort. You can also integrate SFR-based scripts into Let-based systems if you wish. Let me know if you’re interested in other conversions and we can talk about extending the functionality.

Usage

The ParamConverter module provides one script for converting from SFR format to Let Variables and one for converting from Let Variables to SFR format. The most straightforward approach is to create a wrapper script for each Let-based script you’d like to call. This wrapper script will convert the parameters and script results for you. The module includes an example script that shows you how. You can also see it in action in the enhanced demo file for the ErrorHandling module.

To call a Let-based script, just copy the example script from this module and redirect it to the Let-based one.

Integration

Just import the ParamConverter script folder and begin making wrapper scripts.

Issues and To-Do’s

There is an issue converting multi-dimensional (nested) values. Thanks to Jeremy Bante for pointing that out. I will post an update when the issue has been resolved.

Release History

  • 1.0.0 – 11/27/13 – Initial release
  • 1.0.1 – 12/04/13 – Fixed bug translating pairs without whitepace between them
  • 1.0.2 – 12/05/13 – More strict when testing for SFR format
  • 1.1.0 – 1/09/14 – Added ability to temporarily override variable prefix
  • 1.2.0 – 5/13/14 – Added support for multi-dimensional arrays

Download

This project is hosted on GitHub. View the latest release and download it as a .zip package below.

Download ParamConverter

Release history and previous versions are available here.

2 responses to “ParamConverter”

  1. tired eyes says:

    It’s truly a nice and helpful piece of info. I’m glad that you just shared this useful info with us.
    Please keep us up to date like this. Thank you for sharing.

  2. Daniel Smith says:

    Thanks for this module Donovan!

    I recently used it for the first time and noticed the scripts don’t seem to be in the correct folders. The “let to sfr” script, for example, is in the private folder, but the readme say’s it’s in the public folder. Also, the scripts in the public folder look more like configuration scripts to me.

    In my copy I ended up removing invalid characters from the name, when converting from sfr to let. My set of sfr functions fully escaped the name (just like a value) so I could use names like: “table::field”, which is not a valid name for let notation. So, I’m removing/replacing these commonly used (by me, in this particular solution) characters before encoding as let notation. I’m not sure if this is something you’d want to add to the module or not, but it’s something people implementing the module may need to consider.

Leave a Reply

Your email address will not be published. Required fields are marked *