Why won't this compile???

The following code comes up with a “this item does not exist” error;

dim f as FolderItem f= GetOpenFolderItem(".jpg")

Problem is, that this is is a cut an paste I have used from the help file and I have had working before

result=GetOpenFolderItem(filter)

filter: Semicolon separated list of file types the user can open.
The file types must be defined as file types in your project, either in the IDE in a File Type Set or with the FileType class.

have you added the file type to your project?

Yes, but the debug compiler is objecting to the ‘GetOpenFolderItem’ part, not the file spec

This works for me:

drop box download

Thanks for the demo project Torben, but I couldn’t find ‘GetOpenFolderItem’ in the project to prove that it works or not.

Your code looks fine and works fine for me. Are you sure you are not using it in a Console or Web project?

This, however, would be a more appropriate filter:

Dim jpegType As New FileType
jpegType.Name = "image/jpeg"
jpegType.MacType = "JPEG"
jpegType.Extensions = "jpg;jpeg"

dim f as FolderItem = GetOpenFolderItem(jpegType)

Taken from the docs.

[quote=187852:@Jeremy Cowgar]This, however, would be a more appropriate filter:

Dim jpegType As New FileType
jpegType.Name = “image/jpeg”
jpegType.MacType = “JPEG”
jpegType.Extensions = “jpg;jpeg”

dim f as FolderItem = GetOpenFolderItem(jpegType)[/quote]
Thanks Jeremy, but it still breaks on the GetOpenFolderItem line

Your code and my code both work here on my Laptop and Desktop in a Desktop Application. Are you trying to do this from a Console, Desktop, Web or iOS project?

Web

OK, that is the problem. You can not open files on a users desktop from the web, thus GetOpenFolderItem is not available in Web Projects, hence your compile error. To open a user file, you have to use the WebFileUploader which enables the user to open a file and upload it to the server. Then on the server you can work with the file.

Oh, as a little tip, look at the docs for GetOpenFolderItem. At the top, the docs should state what of platforms/types the method supports.

Thanks Jeremy, its pretty obvious when you see it like that. I guess I was deceived by the help file indicating ‘Framework: All’

Yes, that wording is a bit confusing. Maybe @Paul Lefebvre can comment as to what Framework actually means? Seems the Type and OS says all that is needed, or maybe I am confusing things too :smiley: Hm, maybe the Framework is what they are calling the Classic framework or the new Xojo framework. Oh, I see some items such as HTMLViewer.Print, the Framework says Cocoa. So, Cocoa vs. Carbon? Maybe we should just wait for Paul :smiley:

Hi,
I should get a cup of coffee :slight_smile:
it was the wrong link to the drop box. It may not help you yet, because you want to create a web app.

For all others looking at this thread the link for a destop version is:
https://xojo.io/8d58d27c9e2e

“Framework” originally was only used to differentiate between Carbon and Cocoa. But everything is Cocoa now, so it doesn’t really serve much purpose. I’ve removed it from the Support Platforms prompt in the wiki and also changed the other two to be “Project Types” and “Platforms” to match what is displayed in the Summary Boxes of the new docs.