saveAsDialog filter index

I have a problem with the saveasdialog. I want to use several filetypes, but most of them has the same extension (eg files are txt but the content is different). How can i catch the format/filter combobox before saving the file. Is there any chance to do this without using Right(, 3) which is not an option in this case.
Thanks in advance

A file “type” is not determined by its content. If you need files of different types for different purposes, then create you own file types in by adding a FileTypes module to your project. You will set a unique extension (it doesn’t have to be 3 chars.) for each of your types. You can then trap those types when saving or opening a file.

I already created filetypes (this is the way i set the filters). But lets say i have 5 filters with the same extension
Dlg.filter = ft1.txt1 + ft1.txt2… Ft1.txt5
How do i know what to save when the dlg does not return selected filter and the extension of any filter is txt

click on your filetypes in the navigator and set different names to your filetypes (Display Name), that is what you see later in the save dialog.

Use the folderitem.Type property to determine which “Type” from you FileTypes the given file is.

thanks, but it’s not working… f.Type returns nothing

Most likely you haven’t correctly declared the type in your FileTypes module.

I’m not a very experienced xojo programmer, but I declared as follows:

  1. DisplayName = “TxtType1”, ObjectName = “TxtType1”, MacType = “TXT1”, MacCreator = “???”, Extension = “.txt”
  2. DisplayName = “TxtType2”, ObjectName = “TxtType2”, MacType = “TXT2”, MacCreator = “???”, Extension = “.txt”

Dim dlg as New SaveAsDialog
Dim f as FolderItem
dlg.Filter=FileTypes1.TxtType1 + FileTypes1.TxtType2
If f <> Nil then
MsgBox f.Type

End if

Am I doing something wrong?

The whole issue of Universal Type Indicators (UTI) and how they work is still nebulous to me. But I believe the Mac System will not recognize your files as different types as long as they have the same extension. Try naming one .txt1 and the other .txt2 and see what happens.

[quote=82856:@Eduard Schlecht]Hello
files are txt but the content is different[/quote]

what is different ?
txt is plain text

I think you’re confusing content with file type. The content of your file is irrelevant here. By the file types you have set,
DisplayName = “TxtType1”, ObjectName = “TxtType1”, MacType = “TXT1”, MacCreator = “???”, Extension = “.txt”
DisplayName = “TxtType2”, ObjectName = “TxtType2”, MacType = “TXT2”, MacCreator = “???”, Extension = “.txt”
You are indicating that you want 2 DIFFERENT TYPES of files. Those types must have different extensions to be recognized as different types.

I know that files must have different extensions, but in this case its not possible. I want to save some subtitles… the extension is the same, but the contetn of the file differs from one format to another (eg: caption 32, cavena, dvd-junior, cpc-600… all using the same extension). i’ve just wanted to save those different types using a single savedialog and not to create individual menuitems or using a window with a combo on it. Another method which also its not so elegant will be to use eg: txt1, txt2 under filetypes just to make the difference between the formats and on save to change the extension. But its not professional… As a matter of fact, it seems that I have to use one of those “ugly” methods
I don’t understand why a simple function to return dialog’s filter index wasn’t implemented

I don’t understand your insistence on using the same extension for different file types and, in the OSX world don’t believe it is possible. Good luck with whatever it is you are trying to accomplish.