Swi-cs-pl - A CSharp class library to connect .NET languages with SWI-Prolog
SetStreamFunctionWrite Method (streamType, function)
SwiPlCs interface ► SbsSW.SwiPlCs ► PlEngine ► SetStreamFunctionWrite(PlStreamType, DelegateStreamWriteFunction)
This is a primitive approach to enter the output from a stream.

C# | Visual Basic | Visual C++ |
public static void SetStreamFunctionWrite( PlStreamType streamType, DelegateStreamWriteFunction function )
Public Shared Sub SetStreamFunctionWrite ( _ streamType As PlStreamType, _ function As DelegateStreamWriteFunction _ )
public: static void SetStreamFunctionWrite( PlStreamType streamType, DelegateStreamWriteFunction^ function )

- streamType (PlStreamType)
- Determine which stream to use PlStreamType
- function (DelegateStreamWriteFunction)
- A DelegateStreamWriteFunction


static string test_string; static long Swrite(IntPtr handle, string buffer, long buffersize) { string s = buffer.Substring(0, (int)buffersize); test_string = s; return buffersize; } [TestMethod] public void StreamWrite() { // NOTE: the Swrite function is only called if you flush the output or send a newline character string ref_string = "Hello .net world ����"; // The last 4 characters are German umlauts. PlQuery.PlCall("assert( (test_write :- writeln('" + ref_string + "'), flush_output) )"); DelegateStreamWriteFunction wf = new DelegateStreamWriteFunction(Swrite); PlEngine.SetStreamFunctionWrite(PlStreamType.Output, wf); PlQuery.PlCall("test_write"); Assert.AreEqual(ref_string+"\r\n", test_string); }