### Title

Find in a script problems continue

### Post

I am still having problems in a scripted find in a loop so I will ask my question in a different way.

This works but of course I do not want to manually put in n:

P is a field on the form which is in tableView

Enter Find Mode

Show custom Dialog(Input #1:firstprint,Input#2:lastprint

Set field (p;firstprint)

Set Variable($f;Value:firstprint)

loop

exit loop if (p>lastprint)

Show custom dialog(Input#1:p)

perform find[]

Set variable [$f:Value $f+1]

Set Field[p;$f]

End loop

But this does not work:

Enter Find Mode

Show custom Dialog(Input #1:firstprint,Input#2:lastprint

Set field (p;firstprint)

Set Variable($f;Value:firstprint)

loop

exit loop if (p>lastprint)

perform find[]

Set variable [$f:Value $f+1]

Set Field[p;$f]

End loop

Basically if I manually enter a number for P the find works properly. If I enter P from a calculation the find does not increment but remains at the previous p value.

Thanks.

nealt:

Thank you for your post.

Are "firstprint" and "lastprint" global fields? If not, then those values will only be available to the current record when you called the script. Therefore, store those values to variables.

# input your data

Show Custom Dialog [ Input #1:firstprint, Input #2:lastprint ]

# Make sure lastprint is greater than firstprint

If [ firstprint > lastprint ]

Halt Script

End If

# Store firstprint and lastprint to variables $first and $last

Set Variable [ $first ; firstprint ]

Set Variable [ $last ; lastprint ]

Set Error Capture [On]

# Enter Loop

Loop

# Search the P field for the value in $first

Enter Find Mode []

Set Field [ P ; Value: $first ]

Perform Find []

# make sure there are records to print

If [ Get (FoundCount) > 0 ]

<do your print functions here>

End If

# increment $first

Set Variable [ $first ; $first + 1 ]

Exit Loop If [ $first > $last ]

End Loop

Set Error Capture [Off]

---------------

The Set Error Capture allows you to trap errors. I put this in just in case the Find doesn't find a specific value. You can then skip over this value and move on to the next value.

Let me know if you need clarification for any of the above steps.

TSGal

FileMaker Inc.