Hello,
is there a way how to read TProcess.Output (which is of type TInputPipeStream) line by line, please?
I would like to make a simple UI over a legacy prolog program (C executable which embeds swi-prolog). This communicates through standard input/output/error - reads a line from stdin and writes all resolutions to stdout, one by line. I can't use my beloved .Net (= puts the food on my table) for this task* and Java is not a convenient option for this either**. Python suffers from a Global Interpreter Lock and I need real concurrent-running threads. Doing the GUI in C (Gtk+) is total pain in the back and the C++ (Gtk-mm, WxWidgets) are no better. Qt is OK, but in version 5 it takes the 40MB of libraries with itself on Windows and I am not speaking about the hell of setting the C++ environment on Windows other than Visual Studio.
I looked on this tutorial
http://wiki.lazarus.freepascal.org/Executing_External_Programs#Reading_large_output . I am pleased that the API is easy and intuitive, but every code on that page (and even in lazarus-ccr linked from there) is reading the chunks of memory rather than lines. So is there some way how to read whole line from stdout/stderr, please, or I should handle that myself? And if no, how do you break the string/pchar (whatever) into lines? Just UTF8Pos(LineEnding, ...) ?
Thank you very much!
* a) Mono is not preinstalled on targetting linux machines (at university). b) The newest .Net 4.5 does not work on Win XP. But is a replace-update for 4.0 on Win 7 and is preinstalled on Win8 and the beast has different bugs than 4.0, which makes maintenance a nightmare and I pull hair almost every day in my work.
** Mainly because it does not like to return the no-longer used heap memory to the operating system, which is inconvenient when you have a longer running task with peak memory requirements, which this could be. I don't care about its verbosity - I paid for Intellij IDEA Ultimate which helps you handle this (e.g. generates some code for you, hides the ActionListeners inner classes in Swing and displays that as closure etc.) - neither the lack of language features - IDEA has a support for Clojure, which is a lisp on JVM. So I usually use the JVM for university/home projects, but not like to do on this one.