bug-apl
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: libapl apl_exec results displayed as ?


From: enztec
Subject: Re: libapl apl_exec results displayed as ?
Date: Tue, 26 Jul 2022 12:35:43 -0600

Hi,

to get a c library (libapl/apl_exec) working with fpc/freepascal has been made 
pretty easy - to get it working correctly took Jürgen's input

i also had to add ⎕pw←80 in two places (in src/UCS_strings.cc just to get 
libapl to run and right after init_libapl((); in the main fpc libapl pgm to get 
rid of run time divbyzero exceptions
⎕pw was 0 even after init_libapl();

with libapl/apl_exec i am gettting the 0 on stdout as an integer not 
ascii/string with writeln(apl_exec('⍳3')); and the 1 2 3 in something i am not 
able to capture
just doing apl_exec('⍳3');  gives the 1 2 3 but no integer 0 stdout

i can start 'foreign code' (external program)  in a separate process but that 
is not needed for libapl/apl_exec in an fpc pgm - but since i can't capture the 
libapl/apl_exec output into stdout i will have to run apl scripts as separate 
process so that i can capture the output losing the obvious advantage of using 
libapl/apl_exec in the first place

if you have fpc running let me know my fpc library unit for libapl/apl_exec is 
only 1354 bytes (with all my dev scruff still in it. 8 lines of code without 
the scruff). and then include the unit in your program and run init_libapl(); 
and away you go.

I still need to get the correct parameters for init_libapl(); - i am doing it 
just as a procedure with no parameters just init_libapl(); and apl_exec works 
though the init_libapl(); output seems to hint that it needs
some pgm name and logging parameter and path information

that is another reason i would love to capture the libapl output so i don't 
have to see the init_libapl(); output (maybe that is what the logging parameter 
does?)

enztec


On Mon, 25 Jul 2022 10:49:29 -0400
Chris Moller <moller@mollerware.com> 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, enztec@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<moller@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,enztec@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
> >>>
>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]