[Top][All Lists]

[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: Sat, 14 Jan 2023 16:31:48 -0700

Hi Chris

still working on getting fpc to handle the libapl stdout

i have asked fpc people about 
> Does freepascal start foreign code in a separate process?  Without 
> reopening stdout?
and will give their answer when i get it

I have tried to convert your c++ code to fpc but the only stdout i get is '0' 
and not the screen output
i am assuming you have written a c++ header interface to libapl?  i would love 
to add it to my coding examples
i have good c/libapl and python3/lib_gnu_apl coding for my programming work

if you use     apl_exec("⍳4");    in your code do get a string of 7 chars 
to see if c++ handles the libapl while fpc doesn't

is libapl still maintained?  i have tried to make apl_exec return the display 
as an ansistring so i could use
outstring := apl_exec('⍳4'); 
but i am not a c programmer

my fpc headers must be incomplete for this stdout display - but i can do some 
very complicated apl expressions and basically my programs simulate a complete 
apl workspace session.

would you be interested to take a look at what i have done ?

I can get the resulting stdout if i use the programs as separate external 
programs and use the free pascal runcommand function

but i want to use the libapl fpc coding in one fpc program to interact apl with 
fpc completely - it has gotten to complicated using so many separately compiled 
programs and running them as external programs

also for my coding the libapl fpc coding is almost 2x as fast as using the same 
code in apl scripting (external program) and in apl workspace

i compiled libapl with --with-android   see 
but it had no effect on getting the stdout

i have attached my fpc/libapl interface - i left all the test lines i tired 
commented in the file


Hi Thaddy,

your second example is for running an external program which is what i resorted 
to using my libapl/fpc coding but i need one fpc program that can run apl_exec 
and bring the results into the fpc program itself - it gets really complicaed 
having to maintain separate programs for each apl_exec line etc

i used your first code example and it worked for your example but the apl_exec 
stdout was not the screen output display but only the return value (0)

i would be glad to supply my fpc headers and c headers (libapl) but first do 
you have a working apl/libapl installed?

there are c/libapl and python3/lib_gnu_apl (and even lua  headers but i don't 
use them) included with the apl svn source 

i compiled apl from svn source to get libapl/c and lib_gnu_apl/python3 headers 
but don't know if the distro versions have these done

i have c and python3 libapl programs using apl_exec that can test if you have a 
good apl/libapl installation

my fpc headers are simple and use the c/libapl headers and give good 
libapl/apl_exec for some very complicated apl expressions (the apl maintainer 
says that what i am doing shouldn't be doable with what he knows about the 
libapl - libapl is actually c headers for apl and separately authored from apl 

i can do everything i want with apl and fpc using external apl scripting 
libapl/fpc programs using runcommand but the libapl runs the same code almost 
2x faster and 

the libapl (whether fpc/c/python3) appears to be giving it's output to 
something other then stdout 

i believe i am the only person working with fpc-3.2.2 and apl/libapl

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
> >>>

Attachment: libaplu.pas
Description: Binary data

reply via email to

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