A basic loop structure in a FileMaker script would look like this:
# 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
However, this is usually a pretty slow method to query all of your data. There are a number of ways that may be more appropriate. Taking your example, and assuming you are looking for static values in your data, you might do something like this:
# 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 ) ]