FileTypes perhaps?

I have an expression like this in my applicaton.
Where ext was extracted from name property of a folder item.

if ext = ".png" or ext = ".bmp" or ext = ".jpg" or ext = ".tif" then

However each one of these ‘types’ is defined in my fileType1 object.
So rather than go and change this line of code everywhere it’s used each time I add support for a new file type can’t i use some other method that is aware of FileTypes1?

Maybe you could add a public dictionary property on to the app object, add your extension names as keys to the dictionary in the app open event and say throughout your code:

If app.ExtDict.HasKey(ext) then

//do stuff

End if[/code]

Is FileTypes not a class subclassable?

If one is happy with the file types Xojo supports I suppose a simple check if the extension is included in the set without the need to subclass would be:

[code]If Instr(FileTypes1.ALL, Ext) > 0 then

// Do stuff

end if

Otherwise I would consider using dictionaries rather than sub-classing. I prefer to use dictionaries for this type of thing because they provide methods such as HasKey, Keys, Lookup and the Count property and are iterable as in For Each .. Next all for no extra set-up code, and can be modified at run time using Remove, etc.

I used that too, but discovers that if you use one of the default values from the FileType set and drop an application, the application pass successfully the If test and fall into the // Do stuff part.

Also an Else part to reject all unwanted items that ends with a Return is welcome.

Don’t know much about Mac but there’s an Application.AcceptFileTypes read only property for Mac platforms to check the drop list. Might this help?

No - filetypes is not a class that can be subclassed.

No. It was not a question.

In the small defined list of FileTypes, you have:

application/pdf application/rtf

Doing: Instr(FileTypes1.ALL, Ext) will recognize the app file type (as the beginning of application part of the File Type Set…)

How to qualify this “feature” is a good question: bug in the user’s code or bug in Xojo, that is the question.

I resolved that in replacing:

application/pdf application/rtf


item/pdf item/rtf.

Another solution is to not use the shared code but another one. Too late in the afternoon, I forgot it.