Populating Script DB database from Filemaker query on the fly

Ok this is for anyone that has experience using Hanaan Rosenthal’s Script DB osax.

I am using Hanaan’s book as a reference and in it is a sample script; Script 26-7 which is:


tell application "FileMaker Pro"
	tell database "campaign"
		tell table "donors"
			tell (every record whose ¬
				(cell "State" = "RI") and ¬
				(cell "Income" > 100000))
				set address_list to "address"
				set phone_list to cell "tel01"
				set name_list to cell "full name"
			end tell
		end tell
	end tell
end tell

Now, what if I didn’t want to create three seperate lists. What if, instead, I had a Database created in Script DB that contained fields for “full name”, “tel01”, and “address”. How would I populate that database with results of my “tell every record whose…” command in filemaker?

For the record, this is how I ended up accomplishing this:



tell application "FileMaker Pro"
	tell database "campaign"
		tell table "donors"
			tell (every record whose ¬
				(cell "State" = "RI") and ¬
				(cell "Income" > 100000))
				count the records
				set record_count to the result
				set address_list to cell "address"
				set phone_list to cell "tel01"
				set name_list to cell "full name"
			end tell
		end tell
	end tell
end tell

repeat with x from 1 to record_count
	set xAddress to item x of address_list
	set xPhone to item x of phone_list
	set xName to item x of name_list
	set my_db to DB add record {xAddress, xPhone, xName} to db my_db
end repeat