On 7/25/22 11:46, Dr. Jürgen Sauermann wrote:
Hi,0 is an error code, pretty much ⎕ET on page 287 of the APL language reference. The major error code, i.e. ↑⎕ET, is the same as in APL2, the minor error code 1↓⎕ET may differ. It has no relation to ⎕IO.I can't currently see how the result code would make its way to stdout, maybe the caller prints it?Currently the callback gets a const value (so it cannot modify it) and an int telling if the values is committed (aka, assigned to a vatiable) or not (which then causes apl to print it). Maybe think of apl_exec("FOO") to be essentially ⍎"FOO" so that any printouts produced by FOO would be apl output. Not sure, though.As far as (lib-)apl is concerned the callback decides if the result of ⍎"FOO" will be printed.All the magic happens at *StateIndicator.cc* line *542 ff*. Best Regards, Jürgen On 7/25/22 4:49 PM, Chris Moller wrote:Sorry, but I have no idea how the interface between freepascal and C libraries works. If your ⎕io is set to 1, the default, there's certainly no obvious reason for an ASCII 0 to be emitted to stdout. Does freepascal start foreign code in a separate process? Without reopening stdout?On 7/24/22 17:49, enz...@gmx.com wrote:Hi i can see you code is c++ I am working with libapl with fpc (freepascal) and i can capture stdout and stderr fine in fpc coding but the only stdout i get from ap_exec is the 0 i have apl_exec as a function and tried with either of the following definitions function apl_exec(p : pchar) : longint; cdecl; // gives good results displayed but stdout captures only 0 function apl_exec(p : pchar) : ansistring; cdecl; // gives nothing to screen with apl_exec nor any stdout On Sun, 24 Jul 2022 17:16:10 -0400 Chris Moller<mol...@mollerware.com> wrote:apl_exec() can output to both stdout and stderr. I use: std::stringstream outbuffer; std::streambuf *coutbuf = std::cout.rdbuf(); std::cout.rdbuf(outbuffer.rdbuf()); std::stringstream errbuffer; std::streambuf *cerrbuf = std::cerr.rdbuf(); std::cerr.rdbuf(errbuffer.rdbuf()); execerr = apl_exec (cmd.toStdString ().c_str ()); std::cout.rdbuf(coutbuf); std::cerr.rdbuf(cerrbuf); outString = QString (outbuffer.str ().c_str ()); errString = QString (errbuffer.str ().c_str ()); On 7/24/22 16:12,enz...@gmx.com wrote:hello What does libapl output?- the apl_exec function returns 0 to stdout but what is the actual display? for example apl_exec('⍳20') what/where is the 1 to 20 displayed so it can be captured? thanks
OpenPGP_0xDA6C01938888083E.asc
Description: OpenPGP public key
OpenPGP_signature
Description: OpenPGP digital signature