Glad this worked for you!
The documentation is good, but could do with an overhaul in places. That in itself is a massive project... and I'm sure they haver bigger fish to fry (although the importance of good documentation with lots of examples cannot be overstated...)
marksmithhfx wrote: ↑Mon Apr 03, 2023 3:04 pm
Hi Stam, wasn't exactly sure what you meant by "return-delimited list" for showing 1 file type but I tried the following (based on examples you and others presented) and it worked like a charm...
This refers to those dialogs that let you choose
which file type to open - on macOS it's in a popup menu after you click the 'Show options' button or some such. So if you want to provide functionality that lets the user only pick text, or only pick csv, an image etc, use a return delimited list (each definition is in its own line). If you just want to see one or more filetypes without the user having to choose, the just comma delimited list is correct.
Regarding definitions, all you really need is the file extension. I think it used to be more complicated because MacOS had a creator and a filetype code built into the resource fork (which mean you could have files with the same extension opening different default applications) but that's gone by the wayside (thankfully). The list is pipe (|) delimited:
Code: Select all
<custom tag>|<.extension(s)>|<filetype(s)>
but all you need is the middle bit, so you can simply pass leave the first and 3rd pipe-delimited item blank:
Code: Select all
|<extension>, [<ext2>, <ext3>,...]|
So for your example that would be
Code: Select all
put "|sqlite, db|" into tTypes // .db is a common extension for sqlite as well
If you wanted your handler to
either open an sqlite or a text file for example based on
user choice, you would need to populate the popup menu in the OS's open file dialog and you'd need to also provide a tag as well extension(s), as a return-delimited list (1 definition per line):
Code: Select all
put "SQLite|sqlite, db|" & return & "Text file|txt, text, tsv, csv|" into tTypes
here I've added the tags because this populates the popup menu in the OS's open dialog with text. At least that's how I understand it
That's a lot to say about a tiny feature, but hopefully other new users may find this helpful in the future!!
S.