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

Re2: THINK Reference lookup from MCL

Here is some code that actually runs.  Hope it helps you.

(load ":examples:appleevent-toolkit")

(defun strlen (cstring)
  "count the number of chars in a zero terminated string.  Returns the length
	or nil if you don't pass a macptr to the function"
  (if (macptrp cstring)
    (let ((n 0))
        (if (= (%get-byte cstring n) 0)
          (return n)
          (incf n))))

(defun Think-Ref (search-string)
  (with-aedescs (ae target reply)
    (with-cstrs ((my-cstring search-string))
      (multiple-value-bind (psnhigh psnlow)
                           (find-process-with-signature :|DanR|)
        (if psnhigh
          (create-psn-target target psnhigh psnlow)
            (message-dialog "Please launch Think Reference")
            (break "Abort - Think Reference not running")
            ;; you could send a command to the finder to open Think Ref here
      ;; create an apple event
      (ae-error (#_AECreateAppleEvent 
                 :|REF | 
      ;; stuff it with our parameters
      (ae-error (#_aeputparamptr  
                 (strlen my-cstring)))
      ;; send it off
      (send-appleevent ae reply :reply-mode :wait-reply))))

 (Think-Ref "WaitNextEvent")

Jeffrey Kane, MD
Kane Biomedical Systems
Boston, MA

Internet    jbk@world.std.com
Compuserve  74206,640
AppleLink   D0738

[Don't take life too seriously... it's not like anyone gets out of it alive.]