webmastermac Posted July 10, 2002 Posted July 10, 2002 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
BobWeaver Posted July 11, 2002 Posted July 11, 2002 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
webmastermac Posted September 4, 2002 Author Posted September 4, 2002 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?
webmastermac Posted September 4, 2002 Author Posted September 4, 2002 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
Recommended Posts
This topic is 8115 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now