Results 1 to 5 of 5

Thread: python into simba

  1. #1
    Join Date
    Jun 2012
    Location
    THE Students-City of Holland
    Posts
    332
    Mentioned
    0 Post(s)
    Quoted
    4 Post(s)

    Default python into simba

    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?
    Former Name: MasterCrimeZ.
    ToDo: 1. Finish my private bot 2. Make some cool bots for this community 3. Become a member
    If you have any questions about scripting, feel free to PM me

  2. #2
    Join Date
    Aug 2014
    Location
    Australia
    Posts
    932
    Mentioned
    53 Post(s)
    Quoted
    495 Post(s)

    Default

    @slacky;



    New to scripting? Procedures & Functions for Beginners
    Do you use your computer at night? Just get f.lux

  3. #3
    Join Date
    Sep 2014
    Location
    C:\Simba\
    Posts
    565
    Mentioned
    9 Post(s)
    Quoted
    71 Post(s)

    Default

    Feel free to ask me any questions, I will do my best to answer them!

    Previously known as YouPee.

  4. #4
    Join Date
    Feb 2012
    Location
    Norway
    Posts
    995
    Mentioned
    145 Post(s)
    Quoted
    596 Post(s)

    Default

    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.
    Last edited by slacky; 04-11-2016 at 02:52 PM.
    !No priv. messages please

  5. #5
    Join Date
    Jan 2008
    Posts
    33
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    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.

    Code:
        PYProcess.SetCommandline('C:\Users\Matt\AppData\Local\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\Python37-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);

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •