Thanks everyone for the speed

Envoyé à partir de Outlook pour Android<https://aka.ms/AAb9ysg>
________________________________
From: andr...@itship.ch <andr...@itship.ch> on behalf of 
picolisp@software-lab.de <picolisp@software-lab.de>
Sent: Thursday, April 25, 2024 1:34:24 PM
To: picolisp@software-lab.de <picolisp@software-lab.de>
Subject: Re: Stream from call


I obviously meant: check out (in 'lst ...)

not open, sorry!

On 25.04.24 13:33, andr...@itship.ch<mailto:andr...@itship.ch> wrote:

Hi Patrick!

1) for only reading: check out (open 'lst ...) - when (in) gets a list instead 
of a symbol (file) or number (already opened file descriptor), the list is 
evaluated like the (call) arguments and within the (in 'lst ...)-expression the 
input channel is bound to the output channel of the called executable. Then you 
can use (from) (till) (line) (char) etc. to read from it. Same way you can use 
(out) to call another executable and write more stuff to its stdin without 
reading from it.

2) for both reading and writing with the called executable, check out (pipe), 
especially the first form (pipe exe) -> fd which returns a file descriptor. 
Bind it to a variable like (setq OtherProcess (pipe ...)) and then you can use 
it it in subsequent calls like (in OtherProcess ...) and (out OtherProcess ...).

Be aware that the PicoLisp text stream functions (from) (till) (line) (char) 
etc. always read one additional character, which is placed in a look-ahead 
buffer, which can be retrieved with (peek) - depending on how the called 
executable handles stdin/stdout it might matter and you could block reading by 
accident because of the implicit look-ahead mechanism. It's not a big issue, 
but it can matter and then you must be aware of its workings.

Happy lisping,
Andreas

On 25.04.24 13:03, Patrick Lebas wrote:
How can I get the Stream-out from
(call 'ls) and put it into a string  (setq str...) ?  THANKS.
Envoyé à partir de Outlook pour Android<https://aka.ms/AAb9ysg>

Reply via email to