In addition to using Gforth in pipes created by other processes
(see Gforth in pipes), you can create your own pipe with
open-pipe
, and read from or write to it.
c-addr u is the name/path of an OS-level program. If wfam
is r/o
, the standard output of the program is piped into the
Gforth process and can be read from wfileid. If wfam is
w/o
, data written to wfileid is piped as standard input
into the program. wior is 0 if and only if opening the pipe
succeeded.
Closes a pipe wfileid opened with open-pipe
If you write to a pipe, Gforth can throw a broken-pipe-error
; if
you don’t catch this exception, Gforth will catch it and exit, usually
silently (see Gforth in pipes). Since you probably do not want
this, you should wrap a catch
or try
block around the code
from open-pipe
to close-pipe
, so you can deal with the
problem yourself, and then return to regular processing.
the error number for a broken pipe