Create a set of pipe file handlers.
Source position: unix.pp line 150
function AssignPipe( |
var pipe_in: cint; |
var pipe_out: cint |
):cint; |
var pipe_in: text; |
var pipe_out: text |
):cint; |
var pipe_in: file; |
var pipe_out: file |
):cint; |
AssignePipe creates a pipe, i.e. two file objects, one for input, one for output. What is written to Pipe_out, can be read from Pipe_in.
This call is overloaded. The in and out pipe can take three forms: an typed or untyped file, a text file or a file descriptor.
If a text file is passed then reading and writing from/to the pipe can be done through the usual Readln(Pipe_in,...) and Writeln(Pipe_out,...) procedures.
The function returns True if everything went successfully, False otherwise.
In case the function fails and returns False, extended error information is returned by the FpGetErrno function:
|
Pipe file to standard input/output of program. |
|
|
Create FIFO (named pipe) in file system. |
Program Example36; { Program to demonstrate the AssignPipe function. } Uses BaseUnix,Unix; Var pipi,pipo : Text; s : String; begin Writeln ('Assigning Pipes.'); If assignpipe(pipi,pipo)<>0 then Writeln('Error assigning pipes !',fpgeterrno); Writeln ('Writing to pipe, and flushing.'); Writeln (pipo,'This is a textstring');close(pipo); Writeln ('Reading from pipe.'); While not eof(pipi) do begin Readln (pipi,s); Writeln ('Read from pipe : ',s); end; close (pipi); writeln ('Closed pipes.'); writeln end.