July 10, 200223 yr I'm trying to make an "Ultimate" Filemaker find and sort subroutine, where I just pass some lists to the subroutine, and it returns the found fields, sorted in the order I requested. I don't want to bore you w/the entire script, so I'll just ask about the sort part, which is where I'm getting stuck. I know FMP likes to sort in this syntax: sort by {field "State", field "Date"} in order {ascending, descending} So I'm trying to write a script to build that sort from 2 lists. Here's how far I've gotten, but i'm stuck on how to build a list that looks like {field "abc", field "xyz"} . Can someone help? TIA. Dan set theFieldsToSortList to {"State", "Date"} set theSortOrderList to {"ascending", "descending"} tell application "FileMaker Pro" tell database "xyz" set SortFieldList to {} set SortOrderList to {} repeat with i from 1 to the length of theFieldsToSortList set thisSortField to item i of theFieldsToSortList set thisSortOrder to item i of theSortOrderList set SortFieldList to SortFieldList & field & thisSortItem set SortOrderList to SortOrderList & thisSortOrder end repeat sort bySortFieldList in order SortOrderList end tell end tell
July 11, 200223 yr Use this syntax: set fieldlist to {"LastName", "FirstName", "PhoneNo"} set orderlist to {"ascending", "ascending", "descending"} set sortfieldlist to {} set sortorderlist to {} tell application "FileMaker Pro" repeat with i from 1 to (count fieldlist) set itemsortorder to ascending if (item i of orderlist) = "descending" then set itemsortorder to descending set sortfieldlist to sortfieldlist & {a reference to field (item i of fieldlist)} set sortorderlist to sortorderlist & itemsortorder end repeat sort by sortfieldlist in order sortorderlist end tell
September 4, 200223 yr Author Thanks Bob! That SO did it! I've been using this subroutine for a while now and it's been great... Until... I just loaded OS X 10.2 on my computer, and now Filemaker crashes when I invoke this sort subroutine, with the error: The Connection is invalid. I even made a dummy database to test it, and it crashed the dummy too. I'm using FMP 5.5v2. Any ideas?
September 4, 200223 yr Author Never mind. I figured it out myself. I had Tell app "Filemaker" tell database theDatabase -- find code goes here end tell -- sort code goes here end tell for some reason this worked great until 10.2. Now it requires Tell app "Filemaker" tell database theDatabase -- find code goes here -- sort code goes here end tell end tell
Create an account or sign in to comment