2014-04-06 3 views
0

필자는 FileMaker Pro 스크립트가 처음인데 반복 루프와 동일한 것이 있는지 궁금합니다. (예 : C/C++/Java의 for 루프와 유사). 그렇다면 아무도 모범 사례를 볼 수 있습니다. (필자가 FMP 11을 사용한다면 도움이된다.)FileMaker 스크립트의 반복 루프는 무엇입니까?

알고리즘 : 현재 데이터베이스의 모든 레코드를 반복하고 각 레코드의 두 특정 열을 검사하고 특정 숫자가 포함되어 있고 카운터가 증가하면 데이터베이스를 찾고 있습니다. 그런 다음 다음 레코드로 이동하십시오.

감사합니다. 파일 메이커 스크립트

+0

"* 각 레코드에서 두 가지 특정 열을 확인하고 특정 번호를 포함하는 경우 *"는 할 수 없습니다 : 귀하의 예제를 가지고 가서, 당신이 당신의 데이터를 정적 값을 찾고 가정, 당신은 같은 것을 할 수 당신은 **이 레코드들을 찾을 수 있습니까? 찾기는 (대부분의 경우) 빠릅니다. 반복은하지 않습니다. –

답변

1

기본 루프 구조는 다음과 같습니다

# 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) ] 
+0

대단히 감사합니다! 말이된다. 꽤 작은 데이터베이스지만 큰 프로젝트에서 확장 할 수있는 곳에서 디자인되기를 바랍니다. 문서를 너무 잘 작성해 주셔서 감사합니다. – Likeamojay