Skip to main content
Skip table of contents

Extending procedure hooks




This page applies to Harlequin v13.1r0 and later; both Harlequin Core and Harlequin MultiRIP.

Even when a hook is a procedure, in many cases it is desirable to augment the behavior of existing instances of a hook rather than overwriting it. This can be done by concatenating procedures. If the procedures have any parameters, you need to duplicate them so that both the original procedure and the new one can access them.

Where the procedure returns a result (EndPage, for example), it is less clear what should be done. In the case of EndPage, this creates an interaction between the old procedure and the new, which can lead to problems.

The most likely candidate for concatenation is Install. An example follows:

TEXT
<<
  /Install [   % note square brackets, not braces
    currentpagedevice /Install get
    /exec load   % not just exec: it would execute immediately
    { ... additions ... } bind
    /exec load   % executes the new procedure
  ] cvx   % convert to executable procedure
>> setpagedevice

If you print the result, as in:

currentpagedevice /Install get ==

you will see:

{ {...old Install procedure...} -exec- {...additions...} -exec- }

Alternatively, insert the old procedure into the new one to achieve the same result, like this:

TEXT
<<
  /Install { null exec ... additions ... }
  dup 0 currentpagedevice /Install get put
  bind
>> setpagedevice

You may find this variation easier to read; however, remember that bind makes a procedure read-only, so the put operator fails if the procedure was already bound.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.