Veselko Posted March 23, 2005 Posted March 23, 2005 On one list layout, I have a 5 fields. It is possible created a just one script for sorting ascending/descending for all 5 fields?
aaa Posted March 23, 2005 Posted March 23, 2005 Use Getfield() function. It will help you to do whate you want.
Ender Posted March 23, 2005 Posted March 23, 2005 Or use script parameters to branch in one sort script.
Veselko Posted March 23, 2005 Author Posted March 23, 2005 I think that catch is in script parameter, but how to add a script parameter in sort step, when there isn't a calculation? In sort step You must specify a field for sorting.
Ender Posted March 23, 2005 Posted March 23, 2005 Use a global for remembering the last sort, and a script parameter to know what the selected sort is on: If [ Get(ScriptParameter) = "Name" ] If [ gLastSort = "Name Ascending" ] Sort [ Restore ; by Name (Decending) ] Set Field [ gLastSort ; "Name Decending" ] Else Sort [ Restore ; by Name (Ascending) ] Set Field [ gLastSort ; "Name Ascending" ] End If Else If [ Get(ScriptParameter) = "Date" ] If [ gLastSort = "Date Ascending" ] Sort [ Restore ; by Date (Decending) ] ...
Veselko Posted March 24, 2005 Author Posted March 24, 2005 [color:"green"] Use a global for remembering the last sort Yes, that is right. [color:"green"] If [ Get(ScriptParameter) = "Name" ] If [ gLastSort = "Name Ascending" ] Sort [ Restore ; by Name (Decending) ] Set Field [ gLastSort ; "Name Decending" ] Else Sort [ Restore ; by Name (Ascending) ] Set Field [ gLastSort ; "Name Ascending" ] End If Else If [ Get(ScriptParameter) = "Date" ] If [ gLastSort = "Date Ascending" ] Sort [ Restore ; by Date (Decending) ] ... [/color] That solution is OK for one layout. But my application contain almost 50 layouts, and will be very useful to create a dynamic system, one dynamic script for all possibly fields. Something like.... that You shouldn't precise what field is sorting (e.g. "by Date")in script step: Sort [ Restore ; by Date (Decending) ] If can, on some way script parameter do that.... On that way created script can be useful in every future application. ...
Ender Posted March 24, 2005 Posted March 24, 2005 In that case, look into doing it with GetField(). I posted a sample of this a couple months back. In was in a thread about 'dynamic reports' or 'dynamic portals'.
Ugo DI LUCA Posted March 24, 2005 Posted March 24, 2005 Hi, Yes, GetField is the way to go as a start, but could get a bit more complex if the fields format could vary, from Time, Date, Number ot Text. I've posted a demo in the Samples Forums to account for these cases. The demo use a portal but can be used with lists as well.
Veselko Posted March 25, 2005 Author Posted March 25, 2005 In that case, look into doing it with GetField(). I posted a sample of this a couple months back. In was in a thread about 'dynamic reports' or 'dynamic portals'. Sorry but I can't find your posted sample. Can You give me a link, please?
Ender Posted March 25, 2005 Posted March 25, 2005 Here it is, right where I left it. http://www.fmforums.com/threads/showflat.php?Cat=0&Board=layouts&Number=137793 But listen to Ugo too. My basic demo would not handle sorting dates and numbers properly.
Veselko Posted March 25, 2005 Author Posted March 25, 2005 Hi, Yes, GetField is the way to go as a start, but could get a bit more complex if the fields format could vary, from Time, Date, Number ot Text. I've posted a demo in the Samples Forums to account for these cases. The demo use a portal but can be used with lists as well. Thanx Ugo, I'll get back later with my impressions. First I must read Your calc. field very patiently; it's complicated for my skill of filemaker. I hope that will help me.
Veselko Posted March 31, 2005 Author Posted March 31, 2005 Hi again, Thanks everybody for help! I attached my solution for dynamic sort here, and on post in Sample files too. My solution required that every layout have a three extra fields ( text, number and date). They are a temporary fields in which values are copied from desired sort column fields. Now, I have another question. Loop is very slow for thousands records; how can be faster? UGO sent a file RandomCreation few days ago, but unfortunately I can understand it. Can You please, give some extra instruction for using Your faster loop solution? TIA dynamic_sort.zip
Recommended Posts
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