Swi-cs-pl - A CSharp class library to connect .NET languages with SWI-Prolog
SetStreamFunctionWrite Method (streamType, function)
SwiPlCs interfaceSbsSW.SwiPlCsPlEngineSetStreamFunctionWrite(PlStreamType, DelegateStreamWriteFunction)
This is a primitive approach to enter the output from a stream.
Declaration Syntax
C#Visual BasicVisual C++F#
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
)
static member SetStreamFunctionWrite : 
        streamType : PlStreamType * 
        function : DelegateStreamWriteFunction -> unit 
Parameters
streamType (PlStreamType)
Determine which stream to use PlStreamType
function (DelegateStreamWriteFunction)
A DelegateStreamWriteFunction
Examples
 Copy imageCopy
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);
}

Assembly: SwiPlCs (Module: SwiPlCs.dll) Version: 1.1.60601.0 (1.1.60601.0)