PDA

View Full Version : python into simba



Master BAW
04-11-2016, 06:15 AM
Hi there, small question: Is there a way to include python functions into simba somehow and combine it with SRL functions? And what about C/C++ or maybe even Java?

Incurable
04-11-2016, 08:25 AM
slacky;

Joopi
04-11-2016, 12:58 PM
http://docs.villavu.com/simba/pymml.html

slacky
04-11-2016, 02:45 PM
There is no direct way of using python within Simba, no.
You can write native libraries in C, C++, FPC, and other languages capable of building dlls, and then call methods in that dll from Simba.

That does not work with python as python is an interpreter language, and so it can't compile into a dll. And even if you did write a plugin wrapping the whole python engine; python represents datatypes in an entirely different way so it would just be painful to use alongside Lape.

penguII
12-16-2018, 06:00 PM
I found this thread via google but it didnt help me. Here is the solution I came up with now.
I use Tprocess and Python with the -i parameter to use stdinout.


PYProcess.SetCommandline('C:\Users\Matt\AppData\Lo cal\Programs\Python\Python37-32\python.exe -i');
PYProcess.setOptions([poUsePipes]); //, poNoConsole
PYProcess.getParameters.Add('/c');
PYProcess.getParameters.Add('dir /s C:\Users\Matt\AppData\Local\Programs\Python\Python 37-32\');

PYProcess.execute;

//Do Python stuff and write it
readycmd := 'print("hello world from python")'+#10;
PYProcess.getInput().Write(readycmd[1],length(readycmd));

//Read Python answer
repeat
//writeln(AProcess.getOutput().getNumBytesAvailable) ;
count := PYProcess.GetOutput().Read(buf, PYProcess.getOutput().getNumBytesAvailable);
until PYProcess.getOutput().getNumBytesAvailable = 0;

ss := '';
//read python output
for I := 1 to count do
begin
ss := ss + buf[i];
end;


//Here is your python answer
writeln(ss);