FileMaker – マルチプルスクリプトパラメータの受け渡し

FileMaker – Passing Multiple Script Parameters
以下の blockquote部分は上記出典ページの段落、直後の日本語は内容の拙訳です。
※ 万一のトラブルは、出典サイトはもちろん、(たとえそれが僕の拙訳のせいだとしても) 一切関知しませんのであしからず。

素晴らしいカスタム関数を発表してくれた の Jesse Antunes / Geoff Coffey に感謝します。

I can think of hundreds of times when I found myself pounding my head against the desk because I had to define yet another global field just to pass a simple value from one script to another. Like you, I myself hate to have lots of cruft clogging up my databases. Luckily, FileMaker 7+ gave us the wonderful addition of script parameters to help relieve this plight. Sometimes, even this isn’t enough and that’s where passing multiple parameters takes over.

幸運にも、FileMaker 7 以降では、こんな状況を少しは楽にしてくれる スクリプト引数なるものが追加されたわけですが、複数の引数を受け渡したいとかいうことになると、そんなもんじゃ足りなくなることもよくあります。

Whenever a script is chosen in a perform script step, Filemaker shows a box for an optional script parameter. You can type in whatever your programming heart desires or you can click the edit button and take advantage of Filemaker’s many built-in functions to construct a parameter. Many times, when presented with this option you probably find yourself thinking . . . Boy, I wish I had space for a bunch of different parameters. Well with the use of that tiny edit button, a couple of Filemaker’s functions and a little bit of ingenuity this actually ends up being doable. To pass multiple parameters in filemaker we are basically going to make a ¶ delimited list and then crowbar individual parameters out using the MiddleValues().

「にいちゃんよー、一連のパラメータを書く場所がなんとかならんかねー。そのちっぽけな編集ボタンを使って、いくらかの FileMakerの関数を使ったひと工夫でよー。」
FileMakerにおいて、複数の引数を受け渡すには、基本的に、改行区切りリストにぶちこんで、個々の引数を MiddleValues ( ) を使って無理矢理引っ張りだすことになるわけです。

Ok, let’s say we are trying to create a new line item for an order we are going to fulfill for 3 iPhones at a price of $499. We don’t want to have to put the part number (iPhone), the description (”The coolest phone I have ever seen. Wow, it’s also really cheap!”) the quantity(3) and the price($499) in a bunch of different globals to pass our script, so we will just send them in using the script parameter. To do this, select the perform script step and pick the script you are going to call. Then hit the edit button next to the “Optional Script Parameter” box. Filemaker’s trusty old calculation window will pop up and you’re ready to roll. All you have to do is make the parameters you would like to pass into a list like so:

では、たとえば今、499ドルの 3つの iPhone 用に 新しい項目 を作りたいとしましょう。

部品番号 (iPhone) とか、説明 (”The coolest phone I have ever seen. Wow, it’s also really cheap!”) とか、数量 (3)とか、価格 ($499)とかを、スクリプト引き渡しのために一連の別個のグローバルにいちいち入力したかないので、スクリプト引数を使って受け渡したいというわけです。

FileMaker の古式ゆかしい計算ウィンドウがポップアップしたら準備完了です。


Hit Ok and you are done with your parameter passing. Now comes the part where you pop the values you want from the script parameter. To do this we are just going to simply use the MiddleValues() function. The complete signature of Middlevalues() is:

これには、シンプルに MiddleValues ( ) 関数を使うことになります。
この場合の 完全な MiddleValues ( ) の書式は…

Note: Thanks to David Richards (from the comments) and Genx (from for pointing out that you can simplify these calcs using GetValue instead of MiddleValues. We needed FileMaker 7 support for this particular setup, but if you can live with 8+ only, they’re absolutely right. GetValue does not include the trailing ¶ so you can avoid all the mumbo jumbo about cleaning that up.

Note: David Richards (コメント欄から) と Genx ( から) に感謝します。
これらの計算式は、MiddleValues の代わりに、GetValue を使うことでシンプルになることを指摘してくれてありがとう。
私たちは、この特有のセットアップで FileMaker 7 をサポートしなくちゃならないけど (だから MiddleValues で行くわけだけど)、8以降のみなら、彼らは完全に正しいわけです。
GetValue だったら、改行を引きずることもないから、余計なジュゲムジュゲム的記述を削除できるね。

The sole purpose of this function is taking a list of ¶ separated values, exactly like we created in the previous step, and select the values you specify from it. For instance, let’s say we are in the script we called in the first step and we want to get the quantity out of the script parameter. All we would need to do is execute the following bit of code:

この関数の唯一の目的は、(前のステップでやったように) 改行区切りリストを得ることと、そのリストから指定した値を取得することです。
たとえば、最初のステップで呼び出したスクリプトのなかにいて、スクリプト引数から 数量を取り出したいとしましょう。

This step tells Filemaker to start from the third value in the script parameter and return one value which is effectively just saying give me the third value in the list. If you want the fourth value, the price, just change the number 3 to a 4. The one will always stay the same because you wouldn’t really want to get more then one value out of the script parameter at a time. It wouldn’t really make sense in a typical script.

We have the value out, we still aren’t quite finished. The MiddleValues function doesn’t get ride of the annoying ¶ that we tacked on the end of our parameters so to delete it we have to add the following code:

このステップは、FileMaker に スクリプト引数の 3番目の値から 一行取得するということです。

MiddleValue 関数は、パラメータ全体をつなぐ改行を引きずったままなので、改行を削除するためには、以下のコードを追加してやらなければなりません。

This code is a little confusing but it is basically saying if we have a ¶ on the end of our parameter take it off.

Now that you have seen how we plan on getting the values out, you are probably thinking to yourself… What happens if I pass a ¶ in the middle of one of my parameters. This isn’t exactly out of the realm of possibility and it would clearly break your code. For instance if you changed the description on the iphone to read:


たとえば、iPhone の説明をこう変えたとしましょう。:

Unfortunately, Filemaker will mush (concatenate for you technical types) everything together and create the following list:

残念ながら、FileMaker は、すべてを一緒に (数珠つなぎで) まぜこぜにして、以下のようなリストを吐き出すでしょう。

Now, everything has been shifted down one because of that extra ¶ and we can no longer get the price, quantity nor description that we expect. To take care of this we have to escape the ¶ so that it turns it into just a symbol rather then turning it into a new line in your text. To implement this change we will have to change how we create our list. I know I lied to you, you weren’t quite done with creating your parameter list. Here is the function you will need:


Using our new code we would rewrite our last list to:


Not only does this list look a heck of a lot cooler, but it is more functional and a LOT easier to read. OK, we have a custom function to add parameters to a list, we should probably create one to get all that information out so we don’t have to type that horrible blob of code ever again:


Before you go off and pass around parameters all willy nilly, there is one final warning when using this style of parameter passing. To demonstrate it, Let’s go back to our iPhone example. Say that you don’t want to include the quantity just yet, but you still want to send over the price and description. If you tried the following:

デモを行うために、例の iPhone の例に立ち返りましょう。

The $499 will go into the quantity field because your script that creates the line item thinks that the quantity is the third value, but because the quatity isn’t there the price has shifted up into the third position. To alleviate this problem you just need to make sure that you ALWAYS pass all the parameters to a script, even if one is empty. So your parameter list should look like this:

スクリプト的には、数量は3番目の値だと思っているわけですから、$499 は、数量フィールドに入ってしまいますが、実は、数量はそこではなく、その3番目の位置には、繰り上がって価格が来ることになります。

Hopefully, many of you find this quite useful and it will help you build more powerful and less cluttered databases. For those who would like a more technically advanced way of passing parameters, where you can actually associate each parameter with a name, such as qty = 2, then check back soon for another article.

それぞれのパラメータを name と結びつけた (たとえば、gty = 2 みたいに) もっと技術的に進歩的なパラメータ受け渡し方法をお望みの向きには、別記事で。

  1. FileMaker – マルチプルスクリプトパラメータの受け渡し (このエントリ)
  2. マルチプルパラメータのスクリプトへの受け渡し – 応用編
  3. FileMaker Dictionary 関数


  1. […] FileMaker – マルチプルスクリプトパラメータの受け渡し […]

  2. […] FileMaker – マルチプルスクリプトパラメータの受け渡し […]

  3. […] FileMaker – マルチプルスクリプトパラメータの受け渡し […]

  4. […] FileMaker – マルチプルスクリプトパラメータの受け渡し […]