https://bz.apache.org/ooo/show_bug.cgi?id=126186
orcmid <[email protected]> changed: What |Removed |Added ---------------------------------------------------------------------------- Issue Type|DEFECT |ENHANCEMENT --- Comment #3 from orcmid <[email protected]> --- (In reply to oooforum from comment #2) > (In reply to orcmid from comment #1) > > What Apache OpenOffice function are you talking about? > Sorry for lack of informations. > I'm talking about Basic and its Dir internal function: > https://wiki.openoffice.org/wiki/Documentation/BASIC_Guide/ > Files_and_Directories_%28Runtime_Library%29 > > See: https://forum.openoffice.org/en/forum/viewtopic.php?t=76011 > More detailed what I mean Thank you. Here's what I think the difficulty is. The TL;DR: The list provided by the Basic DIR function retrieves file and directory entries in exactly the sequence they are returned by the interface provided by the operating system. It is meant to be only that, with providing higher-level functionality left for user-defined functions that use DIR internally. It is not a defect. That is by design. I am changing this incident report to be for an ENHANCEMENT, not a DEFECT, that senior developers can confirm. I expect this will be closed as not an issue after there is confirmation. WORKAROUND To provide what you want, the usual approach is to define and use a function that scans a directory, employs the wild card filtering, and delivers the result in an Object having a list of directory-information strings that are sorted in some particular manner. The DIR operation is intentionally much lower-level than that, but it provides basic operations that higher-level user-defined functions can use. There might be such solutions already on the Community Forum or other web sites where Basic tips are found. DETAILED BACKGROUND The difference between Basic DIR and command-line utilities such as Unix ls and Microsoft (DOS) DIR, is that *the*utility* sorts the list before presenting it. Those allow you to control the direction of sequencing, and choose which field(s) sequencing is by. That is all in the utility, which provides this above the operating-system API. This is efficient for the utility because it is designed to retrieves a complete list and then sort it once. You can also see the delay of sorting if you access a large directory (especially if you go recursively into subdirectories). As explained in the BASIC Guide, mapping DIR to the operating systems lows-level directory access is intentional and is meant to be limited to a common approach available across all platforms. This means that it delivers whatever the operating system delivers, not what is produced by shell utilities built atop the operating system. The operating system keeps track of where the DIR command is and what the next position is, but it is a position in whatever sequence that directory happens to be in. (Some systems have utilities that sort the directory *in* the file system, in which case a DIR would happen to deliver files in that order.) At the level of the Basic DIR, there is no determination that the BASIC program will retrieve all of the entries or is even interested in all of them. The simple wild-card filtering is usually also provided by the operating system. Any sorting should be done after that filtering, not before, of course. DIR is too simple to do that part. -- You are receiving this mail because: You are the assignee for the issue.
