ParamConverterby Donovan Chandler
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.
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.
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.
- 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
This project is hosted on GitHub. View the latest release and download it as a .zip package below.
Release history and previous versions are available here.