
#Parameters
by Jeremy Bante
Overview
#Parameters is a set of custom functions for serializing name-value pair (dictionary) data in Let Notation, such as for passing multiple parameters to a script. (If you aren’t familiar with Let Notation, it basically looks like the variable-setting part of a call to FileMaker’s Let function. FileMakerStandards.org documents the format and best practices.) Installation instructions are available in the module file. Additional documentation and discussion of this module is available on FileMakerStandards.org.
Credits
This module is the result of work from several contributors to FileMakerStandards.org.
License
Anyone may do anything with this software. There is no warranty.
Download
This module is a subset of the FileMakerStandards.org custom function repository on GitHub. If you are not comfortable working with GitHub, you can download the repository directly. The module file is located at Functions/#Name-Value/FM-Parameters.fmp12 in the repository.
Hey,
This does work great,
but I noticed that when I pass just Char ( 9 ) and Char ( 13 ) as values, that they get evaluated with GetAsDate() added, which messes them up:
# ( “columnDelimiter” ; Char ( 9 ) )
& # ( “rowDelimiter” ; Char ( 13 ) )
returns
$columnDelimiter = GetAsDate ( ” ” ) ;
$rowDelimiter = GetAsDate ( “¶” ) ;
These are easy enough to encode, but this is so close to getting around it altogether that it seems worth hunting down! I imagine this kind of data detection, detached from schema” is something of a bear! I’ll try and take a look when I get a chance.
-Jason
Here’s a fix: https://github.com/filemakerstandards/fmpstandards/pull/4
Thanks Dan! Works great!
Hello Jeremy,
I have found your site to be very informative and your expertise with FileMaker custom functions very impressive!
I’m trying to find a FileMaker custom function that duplicates the Excel “RATE” financial function. I’ve explored the several custom function sites, but none of them has the RATE function that I’m seeking. Upon further research on the Web, I was able to locate an implementation of the RATE function in PHP, which looks as follows:
define(‘FINANCIAL_MAX_ITERATIONS’, 128);
define(‘FINANCIAL_PRECISION’, 1.0e-08);
function RATE($nper, $pmt, $pv, $fv = 0.0, $type = 0, $guess = 0.1) {
$rate = $guess;
if (abs($rate) FINANCIAL_PRECISION) && ($i < FINANCIAL_MAX_ITERATIONS)) {
$rate = ($y1 * $x0 – $y0 * $x1) / ($y1 – $y0);
$x0 = $x1;
$x1 = $rate;
if (abs($rate) < FINANCIAL_PRECISION) {
$y = $pv * (1 + $nper * $rate) + $pmt * (1 + $rate * $type) * $nper + $fv;
} else {
$f = exp($nper * log(1 + $rate));
$y = $pv * $f + $pmt * (1 / $rate + $type) * ($f – 1) + $fv;
}
$y0 = $y1;
$y1 = $y;
++$i;
}
return $rate;
} // function RATE()
Would you be willing to convert this code into a FileMaker custom function? If so, what would you charge? I'm a small FileMaker developer in Reston, Virginia USA and this RATE function would be very useful for a customer of mine.
Please let me know if you're interested…thanks in advance.
Cheers,
EJ McFaul
FileMaker Developer
Reston, Virginia
Email: mrsigcat@aol.com
The git links are broken.
Oops! It looks like we removed a branch from the repository and neglected to update this page. Thanks for catching that, Klaus!
[…] FileMakerStandards.org’s Parameters […]
My FileMaker 14 wish-list:
1. Pass multiple script parameters and script results natively in FileMaker 14
2. Whatever…
[…] UPDATE: this post is quite old. I still thing custom functions are not as portable as they should be. However in any complex solution I use the custom functions. The ones I use are from modularfilemaker.org […]
Found a further issue with the #Parameters function, related to date interpretation. Fractions (1/4″ etc) are (incorrectly?) evaluated as dates, that is, GetAsDate(“1/4”) returns 1/4/2015 for instance.
I’ve corrected this behavior by changing the evaluation in the function as follows:
After Line 59:
IsValid ( GetAsDate ( ~text ) )
ADD:
and ( PatternCount( ~text; “/”) > 1 or PatternCount(~text; “-“) > 1 )
The final section will now look like:
~validDate =
IsValid ( GetAsDate ( ~text ) )
and ( PatternCount( ~text; “/”) > 1 or PatternCount(~text; “-“) > 1 )
and not IsEmpty ( ~number ) ;
This should allow for fractions while still interpreting dates correctly for people who either hyphenate or / their dates; i.e. 1/4” will no longer be parsed as a date, but 1/4/2015 and 1-4-2015 should.
Thanks for catching that, John. I modified the test for text containing numbers with date delimiters being erroneously treated as date data to the module file.
But the test still passed. I double-checked the test, and when I tried your example of # ( “notADate” ; “1/4” ), I got the appropriate text result, rather than what you describe. Are you sure you’re using the latest version of the module?
You know what, I looked at it again and the script I had pulled from github must have been outdated, since the last commit was 2013-12-24. I see there were a couple of updates since then, so perhaps one of the other commits fixed the issue I observed, meaning my change may be fundamentally unnecessary.
[…] ModularFileMakerにあるモジュールのひとつです。 ダウンロードは FileMakerStandards.org の GitHub からダウンロードできます。 […]