Filemaker Pro "next record", also Script Editor behaves differently

So I’m doing this (in part):


Tell application "Filemaker Pro"
	try
		delete every request
	end try

	create request
	set cell "IDnumber" to IDNumber 
	--The variable IDnumber is set earlier in the script
	find

	set r_count to count of records
	set I to 1

	do script "first_record"

	repeat while I is less than or equal to r_count
		set cell "Photo" of current record to file img_path
		--The variable img_path is set earlier in the script
		do script "next_record"
		set I to I + 1
	end repeat

--Note: The FMP scripts first_record and next_record each contain only "go to record/request/page []" (first and next respectively)

So first off, is there a better way to step through items in a found set than the way I’m doing it? I tried using


set cell "Photo" of record I to img_path

but that uses the record number for the whole DB not just the found sub-set.

And second, and perhaps more importantly, why does this work if I run it from Script Editor but does not work from inside FMP?
For example, if the Find returns 3 record, it will set the picture for the first of the three, but not the other two. Setting some debug, it does loop the three times but something clearly goes kerflooey when run inside FMP. In Script Editor it correctly sets each record in the found set to the picture in question.

This is majorly frustrating to say the least.

Thanks!!

PS: This is with Filemaker Pro 8 under Tiger (10.4.7) on an Intel iMac

For anyone searching for a similar issue, I figured this out.

First off, I needed to update to FMP 8.0v3 (I was using v1). That fixed the "do script “next_record” " issue behaving differently in Script Editor than in FMP.

Second, this also fixed it so that after a find I can just do the following instead of that nonsense I was doing before:


set r_count to count of records
set I to 1

repeat while I is less than or equal to r_count
	set cell "Photo" of record I to file img_path
	set I to I + 1
end repeat

Previously, this would erroneously reference whole database instead of just the found set, which is not very usefull.