使用局部变量在filemaker中循环

时间:2013-10-20 03:49:18

标签: filemaker

在C#中进行了一些编程 - 试图使用文件制作者而我无法相信它但我甚至无法让一个简单的for循环工作。

我想要做的很简单:遍历我的“amountOfRooms”字段中的条目数量,并在每个房间的表格中创建一个条目。

听起来很简单,但我无法让它发挥作用。现在我有这个:

Set Variable[$cnt[Customers::AmountOfRooms]; value:1] 
Go to Layout["rooms"(Rooms)] 
Loop 
    Exit Loop If[$cnt = Customers::AmountOfRooms] 
    New Record / Request 
    Set Variable[$cnt; Value: $cnt + 1] 
    End Loop 
Exit Script

未创建新记录。我知道脚本正在运行,因为它确实会进入我的布局,但不会创建任何新记录。我的本地变量有一个“重复”字段 - 不确定如何使用它或它意味着什么?关于如何做这个简单的循环的任何想法?感谢。

1 个答案:

答案 0 :(得分:1)

循环

根据您的关系,第一次迭代时行Exit Loop If[$cnt = Customers::AmountOfRooms]可能相等,因为您将变量设置为其上方三行的值:Set Variable[$cnt[Customers::AmountOfRooms]; value:1]

还有其他方法可以做到这一点,但一种常见的方法是将$i变量与$cnt进行比较,如下所示:

Set Variable [$cnt; Value:Customers::AmountOfRooms]
Go to Layout ["Rooms" (Rooms)]
#
Set Variable [$i; Value:1]
Loop
   Exit Loop If [$i >= $cnt]
   New Record/Request
   Set Variable [$i; Value:$i + 1]
End Loop
Exit Script []


重复次数

在较高级别,您可以将FileMaker变量视为1索引数组。所以陈述:

# Set Repetition 1 of $i to 1
Set Variable [$i; Value:1]
#
# Set Repetition 2 of $j to "Second Array Position"
Set Variable [$j[2]; Value:"Second Array Position"]

相当于:

# Set the first value of array $i to 1
$i[0] = 1;
#
# Set the second value of array $j to "Second Array Position"
$j[1] = "Second Array Position";

用其他一些语言。

阵列比较并不严格,但值得一提,但这是开始思考它们的好方法。无论如何,在这种情况下,您无需担心重复次数。如果您想了解更多信息,可以从这里开始:http://www.filemaker.com/11help/html/scripts_ref1.36.15.html