Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/database/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Database FileMaker脚本中的迭代循环等价物?_Database_Scripting_Filemaker - Fatal编程技术网

Database FileMaker脚本中的迭代循环等价物?

Database FileMaker脚本中的迭代循环等价物?,database,scripting,filemaker,Database,Scripting,Filemaker,我是FileMaker Pro脚本的新手,我想知道是否有一个相当于迭代循环的方法。(如C/C++/Java中的for循环)。如果是这样的话,任何人都有我可以看的例子。(如果有帮助的话,我正在使用FMP11) 算法:我目前有一个数据库,我希望遍历数据库中的所有记录,检查每个记录中的两个特定列,以及它们是否包含特定的数字,然后增加一个计数器。然后移动到下一个记录 谢谢 FileMaker脚本中的基本循环结构如下所示: # Start with a found set of the records y

我是FileMaker Pro脚本的新手,我想知道是否有一个相当于迭代循环的方法。(如C/C++/Java中的for循环)。如果是这样的话,任何人都有我可以看的例子。(如果有帮助的话,我正在使用FMP11)

算法:我目前有一个数据库,我希望遍历数据库中的所有记录,检查每个记录中的两个特定列,以及它们是否包含特定的数字,然后增加一个计数器。然后移动到下一个记录


谢谢

FileMaker脚本中的基本循环结构如下所示:

# Start with a found set of the records you want to investigate (or all records)
#
# Set the counter variable
#
Set Variable [$counter ; Value:0]
#
# Go to the first record
#
Go to Record/Request/Page [First]
#
# Loop until you reach the last record, incrementing counter if appropriate
#
Loop
   If [ table::value = desiredValue ]
      Set Variable [$counter ; Value:$counter + 1]
   End If
   Go to Record/Request/Page [Next ; Exit after last]
End Loop
# Assume we are looking for field1 = value1 and field2 = value2
# 
Enter Find Mode []
Set Field [ Table::field1 ; value1 ]
Set Field [ Table::field2 ; value2 ]
Perform Find []
#
# We have now found all records where field1 = value1 and field2 = value2
# We simply set $counter to the count of found records
#
Set Variable [ $counter ; Value:Get ( FoundCount ) ]
然而,这通常是一种查询所有数据的非常缓慢的方法。有许多方法可能更合适。以您的示例为例,假设您正在数据中查找静态值,您可以执行以下操作:

# Start with a found set of the records you want to investigate (or all records)
#
# Set the counter variable
#
Set Variable [$counter ; Value:0]
#
# Go to the first record
#
Go to Record/Request/Page [First]
#
# Loop until you reach the last record, incrementing counter if appropriate
#
Loop
   If [ table::value = desiredValue ]
      Set Variable [$counter ; Value:$counter + 1]
   End If
   Go to Record/Request/Page [Next ; Exit after last]
End Loop
# Assume we are looking for field1 = value1 and field2 = value2
# 
Enter Find Mode []
Set Field [ Table::field1 ; value1 ]
Set Field [ Table::field2 ; value2 ]
Perform Find []
#
# We have now found all records where field1 = value1 and field2 = value2
# We simply set $counter to the count of found records
#
Set Variable [ $counter ; Value:Get ( FoundCount ) ]

非常感谢!有道理。这是一个相当小的数据库,但我希望它的设计可以扩展到更大的项目。谢谢你把它记录得这么好“检查每一条记录中的两个特定列,如果它们包含一个特定的数字”你能找到这些记录吗?发现(在大多数情况下)很快。循环不是。