Reveal a FolderItem in the Finder With an Apple Event

Use Apple events to tell the Finder to show a FolderItem.

Sub ShowInFinder(f as FolderItem)
    if f is nil or not f.Exists then
        return
    end if
    dim slct as new AppleEvent("misc", "slct", "com.apple.Finder")
    slct.FolderItemParam("----") = f
    If slct.send then
        dim actv as new AppleEvent("misc", "actv", "com.apple.Finder")
        If actv.send then
            //success
        else
            //activate failed
        end if
    else
        //select failed
    end if
End Sub

The first Apple event directs the Finder to select the passed FolderItem; the folder containing the FolderItem will also open. The second Apple event tells the Finder to come to the front.

2015-01-20: the code example is updated for recent Xojo versions.