Docs: FolderItem’s Example

The example below comes from here :

Dim f As FolderItem Dim stream As TextOutputStream f = GetSaveFolderItem("public.text", "Daily Planet Staff.txt") If f <> Nil Then stream = TextOutputStream.Create(f) ' f.MacCreator = "ttxt" Stream.WriteLine("Perry White") Stream.WriteLine("Lois Lane") Stream.WriteLine("Jimmy Olsen") Stream.WriteLine("Clark Kent") // Added on 2014-03-03 Stream.Close End If

I replaced FileTypes1.Text with "public.text", commented out the MacCreator change line and the generated file already have the ttxt creator type.
It may be a good idea to add that this works in the OS X platform.
Do not forget to modify the example intro text.

There are other occurences of FileTypes1.Text in that page.

In fact, I think (but I am not sure at 100%) that the whole lot of examples in that page have to be checked (Movies and QuickTime examples ?) and brought up to date (updated for Xojo in 2014), before the next release (if time allow, this is March 2014 after all).

Changes to the docs should be filed in Feedback, not the forum.

I don’t agree with this in general. The GetSaveFolderItem method requires a string containing the acceptable file types, which can be defined either in that location or in the FileTypes settings. It may work in your specific case, but certainly won’t work in every case.


Care to expand your comment: example on cases it does not works ?

Sure. Say I want to have only text files (and folders of course) listed in the GetSaveFolderItem dialog. Using your code as is, there is no file type defined as “public.text”. Therefore the dialog would display all files regardless of their type. By defining a File type set allows you to make available to the dialog only the type of files relevant. If I want only text files in a folder of 100s of miscellaneous files, your approach won’t let me filter out the ones I’m not interested in.

If, in fact, you DO want to show all files in the folder, you can define a File Type Set to include “special/any” with an extension of ‘*’.

I recommend you review the online help for “filetype”.

Hi Dale,

IThe testing folder does only have folders and text (txt) files, so I do not saw what you describe. But, I already had that on real projects (not testing an example).

Thank you for the explanation.


PS: I usually check off line, prepare the text / images and post later (next morning). So when I read an answer, I do not remember the details. And even when I am sure at 100%, troubles can come and go here or there ;-:slight_smile: