AnsweredAssumed Answered

Sorting a List of Values

Question asked by ralvy on Jan 16, 2010
Latest reply on Jan 17, 2010 by ralvy


Sorting a List of Values


I have a solution where I'd like to add a Backup section to my startup script that backs up the data file (I use a data separation model here) every time the user opens the solution. Let's say the data file is called MyApp_Data.fp7 and I want it to make up to 30 backups in a subfolder called Daily Data Backups, where each backup filename takes this form:




So they end up having no more than one a day, for up to 30 incarnations. I can easily produce the copy of MyApp_Data.fp7 this way with Troi File plugin. I could also do it with FM natively.


But it's the 30-file limit that gets me here. I want to have the script first check to see if there are over 29 files in that subfolder and, if so, delete the earliest ones until the number drops back to 29. Troi File can easily delete any files the script tells it to, but I need a way to tell it what to delete. What Troi File can do for me in this regard is produce a return separated list of filenames of the files found in the Daily Data Backups folder (with its ListFolder function). And I can have FM natively tell me how many are in that list (with the ValueCount function). If I can just sort that list alphanumerically, I can have Troi File delete the first n files on that list, where n = ( ValueCount - 29 ).


But I don't see a way to sort that list of values. Do I need to resort to a utility table in the UI file? What I was thinking is getting the values of the list into a simple one-field table, so that there's a record for each value on the list, and then sort that table, and go from there with Troi File.


But, might there be a direct way to sort a list of values?