Skip to main content
Skip table of contents

Mapping standard input and output: setstdio and setstderr

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

The three %std...% pseudo-devices provide a level of indirection. Though syntactically different, their behavior is akin to that of a PostScript filter. The operator setstdio in statusdict (a standard Adobe feature, though not documented in [RB3]) maps the devices %stdin% and %stdout% to files opened on other devices (that is, it makes the files concerned look as if they are the devices %stdin% and %stdout%). The RIP extension setstderr (also in statusdict) provides the analogous effect for %stderr%.

For example: Say that you have mounted a device %terminal% that implements line-buffered input and output to a terminal. Then you could map %stdin%, %stdout%, and %stderr% to input and output files on this device like this:


CODE
(%terminal%) dup (w) file exch (r) file statusdict begin 1 index setstdio setstderr end


When a file is opened on %stdout% in the usual way, the new file is just connected to the existing file that was passed to setstdio. A write to this new file then results in a write on the original device, %terminal% in the example above:


TEXT
/outfile (%stdout%)(w) file def
outfile (Hello) writestring outfile closefile


The closefile results in a closing of the underlying file so that any access to the file, either using %stdout% (or similar pseudo-device), or using the original file object that was passed to setstdio, produces an error.

The effect of setstdio and setstderr is subject to save and restore, so a restore can reinstate the previous mapping of the pseudo-devices.

See statusdict file and device operators for full details.

JavaScript errors detected

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

If this problem persists, please contact our support.