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, enz...@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?)