1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【FileMaker】前回のスクリプトの結果が更新されずに引き継がれるケース

Last updated at Posted at 2022-12-27

概要

タイトルそのまま。
メインスクリプトの中でサブスクリプトを実行し、サブスクリプトの結果を受け取る処理を複数回行う際に、一つ前のスクリプトの結果が引き継がれることがある。

具体例

上記の事象が起きるスクリプトの一例は以下の通り。

メイン
変数を設定[ $i ; 値: 0 ]
Loop
    変数を設定[ $i ; 値: $i+1 ]
    スクリプトを実行[ 指定: 一覧から ; 「サブ」 ; 引数: $i ]
    変数を設定[ $スクリプトの結果 ; 値: Get(スクリプトの結果) ]
    Exit Loop If[ $i=2 ]
End Loop
サブ
If[ Get(スクリプト引数) = 1 ]
    現在のスクリプト終了[ テキスト結果: 1]
Else
    現在のスクリプト終了[ テキスト結果: ]
End If

この場合、メインスクリプトを動かすと、変数「$スクリプトの結果」は以下のようになります。

$スクリプトの結果
$スクリプトの結果[1] … 1
$スクリプトの結果[2] … 1

スクリプト:サブの4行目でスクリプトの結果を明示しない場合、前回のスクリプトの結果がそのまま引き継がれるようです。

公式ドキュメントによると「サブスクリプトが結果を返さない場合、スクリプト結果の内容は空になります」とありますが、スクリプトの結果を複数回受け取る場合にスクリプトの結果を明示していない場合、前回のスクリプトの結果をそのまま引き継ぐようです。

$スクリプトの結果[2]を空欄にしたい場合は、スクリプト:サブの4行目でスクリプトの結果を明示すると良いです。

サブ
If[ Get(スクリプト引数) = 1 ]
    現在のスクリプト終了[ テキスト結果: 1 ]
Else
    現在のスクリプト終了[ テキスト結果: "" ]
End If

追記

最近の公式ドキュメントには上記のケースが説明されていました。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?