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

Publish and Subscribe



;;;
;;;  Are there any examples of using publish and subscribe in MCL?
;;;  The following piece of code always gets error code -451 when
;;;  trying to create a new section.  I've tried to subscribe to Excel and
;;;  Word editions with the same result.  Can anyone tell me what's wrong with
it?
;;;
(progn
  (require-interface :appleevents)
  (require-interface :editions)
  (traps::_initeditionpack)  ;; only run once
  (setf reply (make-record (:newsubscriberreply :storage :pointer)))
  (rset reply :newsubscriberreply.formatsmask  (+ #$kpictformatmask
#$ktextformatmask))
  (traps::_getlasteditioncontainerused (rref reply
:newsubscriberreply.container))
  (traps::_newsubscriberdialog reply)
  (rlet ((kind :signed-byte)
         (mode :signed-integer)
         (id :signed-long)
         (section (:pointer (make-record section (:sectionrecord :storage
:handle)))))
    (%put-byte kind  #$stpublisher 0)
    (%put-long id 177 0)
    (%put-word mode #$sumautomatic 0)
    (let* ((code (traps::_newsection
                  (rref reply :newsubscriberreply.container)
                  (%null-ptr) ;;this document
                  kind
                  177
                  mode
                  section)))
      (format t "~%code=~a" code)
      (with-dereferenced-handles
        ((ctlh (%get-ptr section)))
        (if (%null-ptr-p ctlh)
          (format t "~%have a null pointer")
          (format t "~%BINGO!"))
        )
      )
    )
  )