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

AE-targets without PPC Brow



The following code fills in an ae desc with target info. It really defaults
the selection of the PPC browser, but I think it will still work if you remove the call to choose-process-dialog.

;---------------------------------------------------------------------------

(defvar $local-target-name "Local")

(defconstant $your-ppc-type-name "XXXXep01") ; where XXXX is your creator type?

(defun parse-zone-str (str)
  ; parse strings of form "machine@zone or "machine:type@zone".
  (let ((start-type (position #\: str))
        (start-zone (position #\@ str)))
    (assert start-zone)
    (values
     (subseq str 0 (or start-type
                       start-zone))
     (if start-type
       (subseq str (1+ start-type) (if start-zone 
                                     (1- start-zone)
                                     (length str)))
       "")
     (subseq str (1+ start-zone) (length str)))))

(defun target-string-target-id (target-string target-id)
  ; Fill in a :TargetID POINTER with data from string.
  (assert (and (macptrp target-id) ; really needs to be a ptr not a handle
               (stringp target-string)))
  (if (string= target-string $local-target-name)
    (setf (pref target-id :TargetID.location.locationKindSelector)
          #$ppcNoLocation) 
    (multiple-value-bind (object-str type-str zone-str)
                         (parse-zone-str target-string)
      (setf (pref target-id :TargetID.location.locationKindSelector)
            #$ppcNBPLocation)
      (setf (pref target-id :TargetID.location.NBPEntity.ObjStr)
            object-str)
      (when type-str
        (setf (pref target-id :TargetID.location.NBPEntity.TypeStr)
              type-str))
      (setf (pref target-id :TargetID.location.NBPEntity.ZoneStr)
            zone-str))))

(defun app-str-port-info (app-str port-info)
  (assert (and (stringp app-str)
               (macptrp port-info)))
  (setf (pref port-info :PortInfoRec.name.nameScript) #$smRoman)
  (setf (pref port-info :PortInfoRec.name.name) app-str)
  (setf (pref port-info :PortInfoRec.name.PortKindSelector) #$ppcByString)
  (setf (pref port-info :PortInfoRec.name.PortTypeStr) $your-ppc-type-name))
  
(defun your-choose-appleevent-target (the-desc 
                                      &key prompt title
         ; zone str of form "machine@zone or "machine:type@zone":
                                       default-target-str
         ; name of application you are trying to link to:
                                       default-app-str)
  : Fills in the-desc.
  ; You must eventually AEDisposeDesc it!
  (rlet ((port-info :PortInfoRec)
         (target-id :TargetID))
    (when (and default-target-str default-app-str)
      (target-string-target-id default-target-str target-ID) ; fill in target-id
      (app-str-port-info default-app-str port-info))
    (choose-process-dialog 
     :prompt prompt :title title 
     :location-name-record (pref target-id TargetID.location)
     :port-info-record port-info
     :default-specified (and default-target-str default-app-str))
    (setf (pref target-id TargetID.name) (pref port-info PortInfoRec.name))
    (ae-error (#_AECreateDesc #$typeTargetID target-id 
               #.(record-length :TargetID) the-desc))
    the-desc))
----------------------------------------
Derek White      	      (-ex Mr. Pascal)
ATG/East        	       (AppleLink: DEREK)