Swi-cs-pl - A CSharp class library to connect .NET languages with SWI-Prolog
SetStreamFunctionRead Method (streamType, function)
SwiPlCs interfaceSbsSW.SwiPlCsPlEngineSetStreamFunctionRead(PlStreamType, DelegateStreamReadFunction)
TODO
Declaration Syntax
C#Visual BasicVisual C++F#
public static void SetStreamFunctionRead(
	PlStreamType streamType,
	DelegateStreamReadFunction function
)
Public Shared Sub SetStreamFunctionRead ( 
	streamType As PlStreamType,
	function As DelegateStreamReadFunction
)
public:
static void SetStreamFunctionRead(
	PlStreamType streamType, 
	DelegateStreamReadFunction^ function
)
static member SetStreamFunctionRead : 
        streamType : PlStreamType * 
        function : DelegateStreamReadFunction -> unit 
Parameters
streamType (PlStreamType)
Determine which stream to use PlStreamType
function (DelegateStreamReadFunction)
A DelegateStreamReadFunction
Examples
 Copy imageCopy
static string ref_string_read = "hello_dotnet_world_����.";     // The last 4 character are German umlauts.

static internal long Sread(IntPtr handle, System.IntPtr buffer, long buffersize)
{
    string s = ref_string_read + "\n";
    byte[] array = System.Text.Encoding.Unicode.GetBytes(s);
    System.Runtime.InteropServices.Marshal.Copy(array, 0, buffer, array.Length);
    return array.Length;
}


[TestMethod]
public void StreamRead()
{
    DelegateStreamReadFunction rf = new DelegateStreamReadFunction(Sread);
    PlEngine.SetStreamFunctionRead(PlStreamType.Input, rf);
    // NOTE: read/1 needs a dot ('.') at the end
    PlQuery.PlCall("assert( (test_read(A) :- read(A)) )");
    PlTerm t = PlQuery.PlCallQuery("test_read(A)");
    Assert.AreEqual(ref_string_read, t.ToString()+".");
}

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