Launch vs Open, Open raises error

I have an app that has lines that have worked without fail for years, using LAUNCH to open up a .jpg stored on a local drive, Apple MAc. BUT but LAUNCH is no longer viable, quote:

This item was deprecated in version 2019r2.1.
Please use FolderItem.Open as a replacement.

However, Open does not work, it calls an exception and the app crashes raising an IOEXCEPTION number 256.

I have no idea what to change as the online documentation for OPEN seems to be a simple substitution of OPEN for LAUNCH, and I don’t see in documentation for using OPEN instead of LAUNCH where I need to change any other lines. ANY advice greatly appreciated, I am not a sophisticated programmer, this is a little home app for my own use, but its extremely useful to me.

Dim FormatMe As String
Dim dbFile As FolderItem

FormatMe = txtXPath.text

dbFile = GetFolderItem(FormatMe,FolderItem.PathTypeShell)
if dbFile <> nil and dbFile.exists then
dbFile.launch ////// / IF I USE dbfile.open INSTEAD, AN EXCEPTION IS RAISED. AN OLDER (COMPILED) VERSION WORKS, BUT IT IS NOW FROZEN AS IS.
Else
MsgBox "Thud, Did not find File: " + FormatMe
end

Have you tried leaving it as it was ?
The old methods may not autocomplete but they still exist and quite likely still work

Use your old code and make a Feedback report on the IOException.

I switched to this recently, maybe it works better for you…?

[code]if infile = nil then
return false
exit
else

//fix for Catalina

#if targetMacOS then
// — Patch to open a Xojo folderitem using [[NSWorkspace sharedWorkspace] openURL:]
// July 28th 2019 - Sam Rowlands

declare function NSClassFromString lib "Foundation" ( inNSClassName as CFStringRef ) as integer
declare Function NSURLfileURLWithPathIsDirectory lib "AppKit" selector "fileURLWithPath:isDirectory:" _
(NSURLClass as integer, path as CFStringRef, directory as boolean) as integer

declare function NSWorkspaceSharedWorkspace lib "AppKit" selector "sharedWorkspace" ( NSWorkspaceClass as integer ) as integer
declare Function NSWorkspaceOpenURL lib "AppKit" selector "openURL:" ( NSWorkspaceSharedInstance as integer, inNSURL as integer ) as boolean

return NSWorkspaceOpenURL( NSWorkspaceSharedWorkspace( NSClassFromString( "NSWorkspace" ) ), _
NSURLfileURLWithPathIsDirectory( NSClassFromString( "NSURL" ), inFile.nativePath, inFile.directory ) )

#else
infile.launch true
return true
#endif
end if

exception
return false[/code]

Hello, this is a bug. I entered a case in Feedback (58856) which is only visible if you ar a beta tester.

Problem:

  • Xojo 2019R2.1 and 2019R3 can not launch files on macOS with folderitem.launch and folderitem.open when the files are copied from an MSDOS (FAT) formatted USB-disc to a macOS filesystem.

  • FolderItem.launch and FolderItem.open also do not launch files when the files are located an an MS-DOS (FAT) formatted USB-Drive. FolderItem.open gives an „miscellaneous error occurred (OSStatus -36)“ message.

ShowURL(FolderItem.URLPath) launches the files, so use ShowURL until this gets fixed.

Norman, if I leave as it was, no error… but no function, nothing happens.

Jeff, appreciate the input but as I noted I am not very sophisticated, your reply is way over my head- BUT as a novice, I do not think the line “infile.launch” in your example would work, launch is obsolete.

Christian, Beatrix: Thank you very much, I too thought it was a bug based on what I found in documentation. I will try the showURL method and see how it works. Definitely appreciate everyones comments/interest.

Not removed, it will work until it will be removed.

However, you are right to stop using it.