[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: libapl stdout
From: |
Dr . Jürgen Sauermann |
Subject: |
Re: libapl stdout |
Date: |
Sun, 19 Feb 2023 12:55:00 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 |
Hi,
two explanations:
1. ⎕FIO does not allow closing of file descriptors 0, 1, and 2 aka.
stdin, stdout and stderr.
Closing them is usually a mistake because it disconnects the interpreter
from its I/O. That
should explain the DOMAIN ERRORs.
2. Files opened with fopen (aka.*⎕FIO[3]*) are buffered. If they refer
to stdout or stderr
then you will probably see the output only after a newline character (which
*rs←(⍕⍳4) *is lacking). The characters not vet written are written on
*fclose()*
but that is certainly not the proper way of enforcing their printout..
Best Regards,
Jürgen
On 2/2/23 10:14 PM, enztec@gmx.com wrote:
Hi Jürgen
this is what i'm testing and i must be missing something -
//apl_exec('h ← "w" ⎕fio[3] "https.tmp"'); // h → 3 good '1 2 3 4' written
to file
//apl_exec('h ← "w" ⎕fio[3] "/dev/stdin"'); // h → 3 '1 2 3 4' written to
screen
apl_exec('h ← "w" ⎕fio[3] "/dev/stdout"'); // h → 3 '1 2 3 4' written to
screen
//apl_exec('h ← "w" ⎕fio[3] "/dev/tty"'); // h → 3 '1 2 3 4' written to screen
//apl_exec('h ← "w" ⎕fio[3] "/dev/stderr"'); // h → 3 '1 2 3 4' written to
screen
//apl_exec('h←0'); // causes domain error
//apl_exec('h←1'); // causes domain error
//apl_exec('h←2'); // causes domain error
//apl_exec('h←3'); // causes domain error
apl_exec('"h :", h');
writeln('1');
apl_exec('rs←(⍕⍳4) ⎕fio[23] h');
writeln('2');
apl_exec('rs←⎕fio[4] h'); // closing causes display on screeb (but not to
stdout?)