how to redirect the console output of prolog inclusive trace or write(…) to c++ Variable

做~自己de王妃 提交于 2019-12-11 23:25:21

问题


I hope someone can help me and thanks a lot to anybody who have an idea :)

this question is related to another one for same project but thematically slightly different thats why seperated it .

Project in shortform:

Prolog is Solving an existing 2D puzzle which i wrot a logic for. visual studio(VS) cli visualize the puzzle/parts. And finaly the interface should be used to display the Solving process (via prolog trace or "write()")step by step in VS

Goal: Get the output from Prolog code including "write()" and/or tracerout output after calling "PL_call_predicate(...)" method in c++ via Interface of SWI-Prolog and store it to eg. string a variable in c++.

What i have tried:

Im setting up a program which should visualize the "solving-process" of a puzzle. Solving is done in prolog. For visualisation i integrate prolog in Visual Studio. Now i try to get not only the Result from Prolog(this is working thanks also Jan Wielemaker) but also the trace output of each step. I tried to redirect consoleoutputs for cout and Console::WriteLine and serveral other related things and i get the output displayed in console Window

BUT PROBLEM IS: i dont get the output from prolog displayed in same console window :O ...

I post another Question you may want to read for aditional background info. This was related to extract the the Result of PL_call_predicate(); returning two lists with puzzle-ID and rotate State. Jan Wielemaker propose to modifie SWI-Stream.h to redirect I/O but i have no clue where to start...

Finaly

i want to collect the trace output of prolog in a variable of c++. This i can later (or better during runtime ) interpret and display the solving process step by step in Visual Studio cli where i display the 2D puzzle. Currently i can extract the result of Prolog and all consoleoutput BUT not the trac output from "PL_call_predicate()". Does anybody have an idea how to do this??

I apologize for the spelling mistakes. Its not my natural Language.

来源:https://stackoverflow.com/questions/56408112/how-to-redirect-the-console-output-of-prolog-inclusive-trace-or-write-to-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!