[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: finder messages



On Sat Feb 13 06:59:50 1993, you write:
  I have created a standalone application with its
  own creator resource and top level loop.  When it writes a file, it sets
  the file's creator resource, and the finder knows to draw the correct
  icon and that double clicking on such a file should open the
  application.  But my application needs to know the pathname of the
  file that was just clicked on.  I presume that there is a simple
  pointer somewhere with that pathname that the top level loop could
  easily access.  Can someone tell me what it is?

For an example of a standalone application that retrieves the pathname
of the file that launched the application, see binhex.lisp in the
Examples folder.

Here's what you need to do:
1. Define a real top level function that you'll invoke after the
   application starts and after you've read the finder parameters.
2. Define a function that is invoked when the application starts up.
   The function should set the top level function to be the real
   top level function (in 1) and should parse the finder parameters
   using the association list returned by (finder-parameters). Accept
   only pairs of the form (:open full-file-name).
Now, assume that the "real top level" function is called 
real-top-level and the startup function is called startup-function

When you save the application, define a startup function:
   (save-application path :init-file nil 
		       :toplevel-function #'real-startup
		       :resources resources :excise-compiler T)
(defun real-startup ()  
  (%set-toplevel #'real-toplevel)
  (handler-bind
    ((file-error #'application-file-error)
     (serious-condition #'application-unexpected-error)
     (warning #'application-ignore))    
    ; process finder selected files if any    
    (let ((file-list (finder-parameters)))
      (when (eq (car file-list) :open)
        (dolist (f (cdr file-list))
	  ;; f is the full filename of the file
	  ;; you can extract the directory/filename/file type etc.
	  ....
mark