File Type Sets: no extension

I want to use File Type Sets. I am going to be opening files that are all in fact TEXT files but often do NOT have (at this time) any extension associated with them. They were produced by a program from many years ago and were produced with no extension attached to them.

I want to filter out files that are CLEARLY not to be opened (JPEG, PNG etc) But I want the user to be able to open Text files with the extension .txt AND open files with no extension. If these “no extension” files turn out to inappropriate files, I can handle that later in code.

How do you specify “no extension” in the File Type Set ? I tried just appending a blank after a ; (semicolon) in the list of acceptable extensions and that did not work.

Thanks for any help. (Mac / El Capitan / Xojo 2015r3)

The closest I can think of is special/any but in an open file dialog I see no way to select only no extension. It would call for filtering the result.

An open file dialog that shows only Text files and noextension ones seems doable as a custom control.

[quote=230612:@Michel Bujardet]The closest I can think of is special/any but in an open file dialog I see no way to select only no extension. It would call for filtering the result.

An open file dialog that shows only Text files and noextension ones seems doable as a custom control.[/quote]

Well, I wonder how you would do that. If you could specify that a filter DID NOT open certain types then you could exclude various image formats. But filter types seem only to specify types that ARE allowed. It seems to me that once you ALLOW special/any, then the user is free to open ANY file in the file system with no filtering whatsoever.

What I would like to do is at least filter out the file types that are clearly “inappropriate” which in my instance would include, among other things, the various Image file types. I cannot see how to do that.

The File Type Set is so your app is “linked” within the OS so your app is considered to open that file. That can mean “opening” the file and it opens your app, or whether your app loads the file if it’s dropped on it.

With .txt, chances are you don’t want your app being the primary, but at least if you FTS it, it’s considered.

The problem with your other request is that AFAIK there is no “non-definition” in Mac (or WIn for that matter). In other words, there isn’t any definition for files that aren’t typed, only ones that are typed.

Mac’s in recent years have started using the “extension” as kind of a automatic typing. For example you can create a .EXS file and you don’t have to assign anything to FolderItem.MacType or FolderItem.CreatorCode to the file. The OS gives it those rights just by virtue of the extension. So if a file doesn’t have an extension, and is usually not intrinsically typed (MacType/CreatorCode), you don’t have any tools to work with to facilitate recognition.

The easy answer is that your only choice is to accept everything. If you want to get file-content-specific, accept EVERYTHING and use the DragEnter method to discover incoming files and you can load them or check their names and return true or false if you want them to be accepted.

[quote=230649:@Robert Livingston]Well, I wonder how you would do that. If you could specify that a filter DID NOT open certain types then you could exclude various image formats. But filter types seem only to specify types that ARE allowed. It seems to me that once you ALLOW special/any, then the user is free to open ANY file in the file system with no filtering whatsoever.

What I would like to do is at least filter out the file types that are clearly “inappropriate” which in my instance would include, among other things, the various Image file types. I cannot see how to do that.[/quote]

IMO, You cannot have a regular file opener show only text and no extension as text (there may be declares but I don’t recall having seen any). The only possibility with the regular dialog is to go special/any, accept everything, and discard after return all other results than text, and no extension that fit your criteria.

When I wrote I thought it was doable, I referred to a custom control built from a Listbox, which uses http://documentation.xojo.com/index.php/FolderItem.Item to look at the content of a folder to present the user with only *.text and non extension files. It is not very difficult to do, it is just a lot more work than a simple GetOpenFolderItem.