March 23, 200421 yr Hi I have transferred some scripts from a sample database (SortDemo) which doesn't work in my database. I had to do some alterations due to FMv3 to v6 script differences. All I want to do is sort a list view of records by 3 different fields and have the column header (icon) change to show it is the column being sorted and also a toggle set for Ascending/descending. Part of the script follows, there are other parts to the script, but they all seem to follow similar lines to this - the one thing that puzzles me is that there is no scripted reference to the name of the field to be sorted - which is 'Composer' If[""SortOrder" = GetRepetiton(GlobalGS, 1)"] SetField["SortOrder", "GetRepetition(GlobalGS, 2)"] If[""SortComposer" = GetRepetition(GlobalGS, 3)"] PerformScript[sub-scripts,"SortComposer<<"] SetField["SortStatus",""Composer descending""] EndIF The subscript for "Sort Composer" is Sort[Restore, No Dialog] - where 'GlobalGS' is my repeating field containing my graphics for the highlighted column icon and 'SortOrder' contains an icon for ascending/descending - the field to be sorted is 'Composer' Sorting seems to me to be the hardest thing to do in Filemaker ! Cheers C Version: v6.x Platform: Mac OS X Panther
March 23, 200421 yr My guess (from the description of the demo) is that the field Composer is used by the Sort Composer script to sort. I also guess that Composer is a calculation field with a GetField() in it. If so, check that the GetField will return the names of the fields in your database that you want to sort by.
March 23, 200421 yr Author Hi Thanks Sam, but that makes no sense to me (I am new to FM !) The field Composer is just that, - a Text field for my Composer listing of my Classical CD's. All the other fields are Global. This is the crux of my problem, because in the demo file, there seems to be no reference in any of the scripts to the actual field name that needs to be sorted. So I am finding it very difficult to work out how it does a sort at all ! Would it help attaching my file with 4 records in ?? Cheers C Version: v6.x Platform: Mac OS X Panther
March 23, 200421 yr Madwolfie said: The subscript for "Sort Composer" is Sort[Restore, No Dialog] Print out that script. You'll see what sort order is stored. Version: v5.x Platform: Windows 2000
March 24, 200421 yr There are two basic ways to have variable sorts: scripting and using a GetField() as the sort field. You're using scripting. Create a sub-script for each field combination you want to sort on, Sort[Restore, No Dialog] step. For each field combination you want to sort on: 1) Sort by the field combination (e.g. LastName then FirstName in the Sort dialog). 2) Open the ScriptMaker... and then open the script for that field combination. 3) Close the script: a dialog will, click the radio button Replace next to Sort Order & click OK. 4) Click Done Does this make sense?.
March 24, 200421 yr Author Hi Sam I have seen a reference to this before - I have tried this again, and if I understand correctly - you sort the field you want - THEN open Scriptmaker and do an Edit/Save with Replace. This has had no effect - so I assume that there is something wrong with the script - as even the toggle up/down button doesn't change when clicked. Something more fundamental is wrong I feel Thanks for the help - it has been filed in the old grey matter (well, what is left of it !) Cheers Version: v6.x Platform: Mac OS X Panther
March 24, 200421 yr Can you post the file or a screenshot of the script? It'll be a lot easier to diagnose.
March 24, 200421 yr Author Hi Sam Here goes file attached. Hope you can help c Version: v6.x Platform: Mac OS X Panther ClassicalCopy.fp5.zip
March 24, 200421 yr I used both methods, manually sorting, opening the script, closing and replacing the sort order; and deselecting the 'No dialog' checkbox for the sort, performing the script, opening it again, selecting the 'No dialog' checkbox, closing the script and replacing. Both work fine. Make sure when you do the sort that you select the field in the Sort Order column and then select the 'Descending order' radio button or else it will always sort in ascending order.
March 24, 200421 yr Author I did -)) Still no Joy, I have attached a screen shot of the script in the hope that this helps - I think that the first few lines are supposed to swap the contents a global field called (SortOrder) from an up arrow to a down arrow to show the sort order of the following fields in the script. Even this step doesn't work.
March 24, 200421 yr C, you need to wrap your head around the following FileMaker 6 concepts: 1. A script can only store one sort order. 2. However, that script can reference as many subscripts as you like, each with its own sort order. 3. You cannot directly specify a sort order in a script. You must first do a sort, then create the script with a sort(restore) step. 4. If you want to change an existing sort script step, again you must first do a sort, then open the script in question, click OK, and when prompted to keep or replace the existing sort order, choose Replace. 5. The Sort dialog itself can be confusing. When you move a field from the left-hand list to the right-hand Sort Order list, it defaults to Ascending order. To change that, you must first click the field in the Sort Order list, THEN click the radio button below (e.g. Descending). I'm looking at your file. 1. Your Sort scripts do not need to have a Go to Field step, that has no effect on the sort order. 2. Your master Sort script is trying to compare the values in two container fields. That won't work. The only boolean result you can get from a container AFAIK is whether it is empty or not. You need to use a text or number field to do your If() test on, e.g. Sort Status in your example. That's all I have time for right now.
March 24, 200421 yr Here's your file back with sorting fixed. Read Tom's advice in the previous post. Take apart and analyze what I did to get this to work. I deleted the contents of your scripts (except for the >> and << scripts which just had a Sort), and renamed some scripts. I got rid of the repeating field, it is bad programming form because it is not easy to understand what it does. I replaced it with 4 globals with aporpos names. I changed a bunch of the globals to calculations. Most functions don't work on containers, but a calculation can determine whcih container to return. I used this idea to set all the contains based on two fields: Sort.By, which has the text of what is being sorted by, and Sort.Ascending?, a boolean (number 0 or 1). I put an arrow on each heading for the sort order. All the headings share the same order, you can make it so each heading keeps its sort order. If you click on an arrow that isn't visible, the button script knows to sort by that column instead of changing the sort order. Have fun!!! Version: v7.x Platform: Mac OS X Panther ClassicalCopy.zip
March 27, 200421 yr Author I have sorted this sort problem myself. Anyone who would like to know how please post Cheers Version: v6.x Platform: Mac OS X Panther
March 27, 200421 yr OK, I'm curious, how did you do it? Was it different than what I uploaded for you?
Create an account or sign in to comment