// Check the error code.
if sh.ExitCode <> 0 then f.parent.open
The code works fine but the analyser complains ToText if deprecated, but nothing else works. If I take it out the compile fails, expecting Text but got String. ToText works but the analyser doesn’t like it.
What should it be?
var cmd as Text
var sh as new Shell
// Hightlight the file in Finder.
// Build a shell command
cmd = "open -R """+ f.NativePath.ToText + """"
// and execute it
sh.Execute cmd
// Check the error code.
if sh.ExitCode <> 0 then f.parent.open
The original has curly quotes because they were pasted into a quote field, rather than a code option. Always use the </> button when pasting code, it prevents this sort of problem and makes everything more readable.
var cmd as String // Don't use Text here.
var sh as new Shell
// Hightlight the file in Finder.
// Build a shell command
cmd = "open -R """ + f.NativePath + """" // Then you don't need ToText here.
// and execute it
sh.Execute cmd
// Check the error code.
if sh.ExitCode <> 0 then f.parent.open
Yes, the is what the </> button does. You can press it and then paste your code, it goes into the right place. It also allows you to work on an iPhone (which doesn’t seem to offer the back apostrophe on the keyboard.
Maybe you didn’t see the other post where someone gave us the code to reveal item in Finder using Declare:
Declare Function objc_getClass Lib "libobjc.dylib" ( name as CString ) as ptr
Declare Function sharedWorkspace Lib "AppKit" selector "sharedWorkspace" ( obj As ptr ) as ptr
Declare Function selectFile Lib "AppKit" selector "selectFile:inFileViewerRootedAtPath:" ( obj as ptr, fPath as CFStringRef, rootFullPath as CFStringRef ) as Boolean
Dim workspace as ptr = sharedWorkspace( objc_getClass( "NSWorkspace" ) )
' assert ( workspace <> nil, CurrentMethodName + " is Nil")
Call selectFile( workspace, CetElt.NativePath, "")