Swi-cs-pl - A CSharp class library to connect .NET languages with SWI-Prolog
SetStreamFunctionRead Method (streamType, function)
SwiPlCs interface ► SbsSW.SwiPlCs ► PlEngine ► SetStreamFunctionRead(PlStreamType, DelegateStreamReadFunction)
TODO

C# | Visual Basic | Visual C++ |
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 )

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


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()+"."); }