Swi-cs-pl - A CSharp class library to connect .NET ... · The first version of this Interface was...

334
Swi-cs-pl - A CSharp class library to connect .NET languages with SWI-Prolog SbsSW.SwiPlCs Abstract This document describes a CSharp interface to SWI-Prolog . The described interface provides a layer around the C-interface for natural programming from C#. The interface deals with automatic type- conversion to and from Prolog, mapping of exceptions and making queries to Prolog in an easy way. There is a call-back from Prolog to C# Introduction The first version of this Interface was more or less a port of the C++ interface. Now the naming is more '.Net' like and the interface provides a number of features that make queries to SWI-Prolog very easy and powerful. Using programmable type-conversion (casting), native data- types can be translated automatically into appropriate Prolog types. Automatic destruction deals with most of the cleanup required. Acknowledgements I would like to thank Jan Wielemaker for answering many questions and for his comments. Also to Arne Skjærholt for the 64-Bit version (SwiPlCs64.dll) and Batu Akan for the Mono code. Foutelet Joel provide the F# sample. Download binaries Here is the link to download the latest binaries or older versions. Download page There is also a copy on SWI-Prolog Twiki page and SWI-Prolog contrib page . The latter might be outdated. At present I only publish the binaries including the documentation. The sources, which are now under LGPL 2, might be published later. If you like to see them or work on them don't hesitate to contact me via mail. Versions The latest version work with SWI-Prolog 6.3.1 and higher.

Transcript of Swi-cs-pl - A CSharp class library to connect .NET ... · The first version of this Interface was...

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-Prolog

SbsSW.SwiPlCs

AbstractThisdocumentdescribesaCSharpinterfacetoSWI-Prolog.ThedescribedinterfaceprovidesalayeraroundtheC-interfacefornaturalprogrammingfromC#.Theinterfacedealswithautomatictype-conversiontoandfromProlog,mappingofexceptionsandmakingqueriestoProloginaneasyway.Thereisacall-backfromPrologtoC#.

IntroductionThefirstversionofthisInterfacewasmoreorlessaportoftheC++interface.Nowthenamingismore'.Net'likeandtheinterfaceprovidesanumberoffeaturesthatmakequeriestoSWI-Prologveryeasyandpowerful.Usingprogrammabletype-conversion(casting),nativedata-typescanbetranslatedautomaticallyintoappropriatePrologtypes.Automaticdestructiondealswithmostofthecleanuprequired.

AcknowledgementsIwouldliketothankJanWielemakerforansweringmanyquestionsandforhiscomments.AlsotoArneSkjærholtforthe64-Bitversion(SwiPlCs64.dll)andBatuAkanfortheMonocode.FouteletJoelprovidetheF#sample.

Downloadbinaries

Hereisthelinktodownloadthelatestbinariesorolderversions.DownloadpageThereisalsoacopyonSWI-PrologTwikipageandSWI-Prologcontribpage.Thelattermightbeoutdated.AtpresentIonlypublishthebinariesincludingthedocumentation.Thesources,whicharenowunderLGPL2,mightbepublishedlater.Ifyouliketoseethemorworkonthemdon'thesitatetocontactmeviamail.

Versions

ThelatestversionworkwithSWI-Prolog6.3.1andhigher.

TheAssemblyVersionnumber,e.g.1.1.60301.0,canbeinterpretedasfollows:

1-majorversion

1-minorversion

60301-SWI-Prologversion6.3.1(testcasesrunagainstthisprologversion)

0-patchlevelversion

Gettingstarted

CopySwiPlCs.dllorSwiPlCs64.dllandSwiPlCs.XMLwhereeveryouwantandaddinyourprojectareferencetoSwiPlCs.dll.

AfterthatIntelliSenseandtooltipsshouldbeavailable.

screenshot

Makesurethatlibswipl.dllanditsdependenciescouldbefoundbythesystem.Forthesamplebelowitislibswipl.dllandpthreadVC.dll.Forabigapplicationitcouldbealotmore.

TIP:FordevelopmentaddtheSWI-prologbindirectorytothePATHenvironmentvariable.NOTE:Don'tforgettorestartVisualStudioafterthat.VSmustrecognizethenewenvironmentfordebugging.

BasicallywindowssearchfirstinthefolderwheretheexecutableresistthaninthewindowssystemdirectoryandatleastinthedirectoriesthatarelistedinthePATHenvironmentvariable.Fordetailssee"Dynamic-LinkLibrarySearchOrder"

Iflibswipl.dlloroneofitsdependenciescouldnotfoundyouwillreciveanerrorlikeSystem.IO.FileNotFoundException:DasangegebeneModulwurdenichtgefunden.(AusnahmevonHRESULT:0x8007007E)

Copy

Anothercommonerroris:SWI-Prolog:[FATALERROR:Couldnotfindsystemresources]Failedtoreleasestacks

TofixthisaddtheSWI_HOME_DIRenvironmentvariableasdescribedinSWI-PrologFAQFindResourceswithastatmentlikethisbeforcallingPlEngine.Initialize.

Environment.SetEnvironmentVariable("SWI_HOME_DIR",

@"the_PATH_to_boot32.prc");

Firstprogram

AsamplesaysmorethenIwanttowritehere.

C#

usingSystem;

usingSbsSW.SwiPlCs;

namespaceHelloWorldDemo

{

classProgram

{

staticvoidMain(string[]args)

{

//Environment.SetEnvironmentVariable("SWI_HOME_DIR",@"the_PATH_to_boot32.prc");

if(!PlEngine.IsInitialized)

{

String[]param={"-q"};//suppressinginformationalandbannermessages

PlEngine.Initialize(param);

PlQuery.PlCall("assert(father(martin,inka))"

PlQuery.PlCall("assert(father(uwe,gloria))"

PlQuery.PlCall("assert(father(uwe,melanie))"

PlQuery.PlCall("assert(father(uwe,ayala))"

using(PlQueryq=newPlQuery("father(P,C),atomic_list_concat([P,'is_father_of',C],L)"

{

Copy

foreach(PlQueryVariablesvinq.SolutionVariables)

Console.WriteLine(v["L"].ToString());

Console.WriteLine("allchild'sfromuwe:"

q.Variables["P"].Unify("uwe");

foreach(PlQueryVariablesvinq.SolutionVariables)

Console.WriteLine(v["C"].ToString());

}

PlEngine.PlCleanup();

Console.WriteLine("finshed!");

}

}

}

}

HereishowtousethelibraryinF#.MannythankstoFouteletJoelforthissample.

F#

//LearnmoreaboutF#athttp://fsharp.net

openSystem

openSbsSW.SwiPlCs;

letple=PlEngine.IsInitializedin

ifplethenprintfn"Echecinitialisation"else

begin

PlEngine.Initialize([|"-q"|])

PlQuery.PlCall("assert(father(martin,inka))"

PlQuery.PlCall("assert(father(uwe,gloria))"

PlQuery.PlCall("assert(father(uwe,melanie))"

PlQuery.PlCall("assert(father(uwe,ayala))"

letq=newPlQuery"father(P,C),atomic_list_concat([P,'is_father_of',C],L)"

begin

Seq.iter(fun(x:PlQueryVariables)->printfn

printfn"allchild'sfromuwe:"

letr:PlQueryVariables=q.Variables

Seq.iter(fun(x:PlQueryVariables)->printfn

end

PlEngine.PlCleanup()

printfn"%A""finished!"

end

ForfurthersamplesseetheexamplesinSbsSW.SwiPlCsandSbsSW.SwiPlCs.PlEngine.

TheclassSbsSW.SwiPlCs.PlQueryisthekeytoaskSWI-Prologforproofsorsolutions.

TheSbsSW.SwiPlCs.PlTermplaysacentralroleinconversionandoperatingonPrologdata.

KnownBugs

SbsSW.SwiPlCs.PlEngine.Initializework*not*asexpectediftherearee.g.Germanumlautsintheparameterse.g.inthepathorfilenameforaqlffile(switch-x)SeemarshallinginthesourceNativeMethods.cs

byUweLesta,SBS-SoftwaresystemeGmbH

C#SwiPlCsinterface►SbsSW.SwiPlCs

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-

PrologSbsSW.SwiPlCsNamespace

Theonlinedocumentationhomeishere.

ThisnamespaceSbsSW.SwiPlCsprovidesan.NETinterfacetoSWI-Prolog

Overview

PrologvariablesaredynamicallytypedandallinformationispassedaroundusingtheC-interfacetypeterm_twitchisanint.InC#,term_tisembeddedinthelightweightstructPlTerm.ConstructorsandoperatordefinitionsprovideflexibleoperationsandintegrationwithimportantC#-types(string,intanddouble).

Thelistbelowsummarisestheimportantclasses/structdefinedintheC#interface.

class/struct ShortdescriptionPlEngine Astaticclassrepresentstheprologengine.

PlTerm Astructrepresentingprologdata.

PlTermV AvectorofPlTerm.

PlQuery AclasstoqueryProlog.

DeclarationSyntaxC# VisualBasic VisualC++

namespaceSbsSW.SwiPlCs

NamespaceSbsSW.SwiPlCs

namespaceSbsSW.SwiPlCs

TypesAllTypes Classes Structures Enumerations

Icon Type DescriptionPlEngine Thisstaticclassrepresentstheprolog

engine.

PlFrameTheclassPlFrameprovidesaninterfacetodiscardunusedterm-referencesaswellasrewindingunifications(data-backtracking).Reclaimingunusedterm-referencesisautomaticallyperformedafteracalltoaC#-definedpredicatehasfinishedandreturnscontroltoProlog.InthisscenarioPlFrameisrarelyofanyuse.

ThisclasscomesintoplayifthetoplevelprogramisdefinedinC#andcallsPrologmultipletimes.Settingupargumentstoaqueryrequiresterm-referencesandusingPlFrameistheonlywaytoreclaimthem.

PlQueryThisclassallowsqueriestoprolog.

AquerycanbecreatedbyastringorbyconstructingcompoundtermsseeConstructorsfordetails.

AllresourcesantermscreatedbyaqueryarereclaimedbyDispose().Itisrecommendedtobuildaqueryina

usingscope.

TherearefourpossibleopportunitiestoqueryProlog

Querytype DescriptionAstaticcall Toaskprologfor

aproof.Returnonlytrueorfalse.

APlCallQuery(String)

Togetthefirstresultofagoal

ConstructaPlQueryobjectbyastring.

Themostconvenientway.

ConstructaPlQueryobjectbycompoundterms.

Themostflexibleandfast(runtime)way.

ForexamplesseePlQuery(String)andPlQuery(String,PlTermV)

PlQuerySwitch Flagsthatcontrolfortheforeignpredicateparameters

SWI-PrologManual-9.6.16QueryingProlog.

PlQueryVar RepresentsonevariableofaQueryresult.

PlQueryVariablesRepresentsthesetvariablesofaQueryifitwascreatedfromastring.

ThisclassisalsousedtorepresenttheresultsofaPlQueryafterToList()orSolutionVariableswascalled.

PlTermThePlTermstructplaysacentralroleinconversionandoperatingonPrologdata.

PlTermimplementsIComparabletosupportorderingin[!:System.Linq]queriesifPlTermisaList.

CreatingaPlTermcanbedonebytheConstructorsorbythefollowingstaticmethods:

PlVar(),PlTail(),PlCompound,PlString(),PlCodeList(),PlCharList()(seeremarks)

PlTermV ThisAPIispreliminaryandsubjecttochange.

Thistypeisusedtopasstheargumentstoaforeigndefinedpredicate(seeDelegateParameterVarArgs),constructcompoundterms(seePlCompound(String,PlTermV)andtocreatequeries(seePlQuery).

Theonlyusefulmemberfunctionistheoverloadingof[],providing(0-based)accesstotheelements.Item[Int32]Rangecheckingisperformedand

Copy

Copy

raisesaArgumentOutOfRangeExceptionexception.

PlType Obtainthetypeofaterm,whichshouldbeatermreturnedbyoneoftheotherinterfacepredicatesorpassedasanargument.ThefunctionreturnsthetypeofthePrologterm.Thetypeidentifiersarelistedbelow.

Examples

BeforegoingintoadetaileddescriptionoftheCSharpclassesletmepresentafewexamplesillustratingthe`feel'oftheinterface.TheAssertclassinthesampleisfromthetestframeworkandhasnothingtodowiththeinterface.Itshowsonlywhichreturnvaluesareexpected.

Creatingterms

ThisverysimpleexampleshowsthebasiccreationofaPrologtermandhowaPrologtermisconvertedtoC#-data:

C#

PlTermt1=newPlTerm("x(A)");

PlTermt2=newPlTerm("x(1)");

Assert.IsTrue(t1.Unify(t2));

Assert.AreEqual("x(1)",t1.ToString());

CallingProlog

Thisexampleshowshowtomakeasimplecalltoprolog.

C#

Copy

Copy

Copy

PlTerml1=newPlTerm("[a,b,c,d]");

Assert.IsTrue(PlQuery.PlCall("is_list",l1));

Gettingthesolutionsofaquery

Thisexampleshowshowtoobtainallsolutionsofaprologquery.

PlQuerytakesthenameofapredicateandthegoal-argumentvectorasarguments.Fromthisinformationitdeducesthearityandlocatesthepredicate.themember-functionNextSolution()yieldstrueiftherewasasolutionandfalseotherwise.IfthegoalyieldedaPrologexceptionitismappedintoaC#exception.

C#

PlQueryq=newPlQuery("member",newPlTermV(newPlTerm(

while(q.NextSolution())

Console.WriteLine(s[0].ToString());

ThereisanotherconstructorofPlQuerywhichsimplifythesampleabove.

C#

PlQueryq=newPlQuery("member(A,[a,b,c])");

foreach(PlTermVsinq.Solutions)

Console.WriteLine(s[0].ToString());

AnotherwaytogettheresultsistouseSolutionVariablestoiterateoverPlQueryVariables.

C#

PlQueryq=newPlQuery("member(A,[a,b,c])");

foreach(PlQueryVariablesvarsinq.SolutionVariables)

Console.WriteLine(vars["A"].ToString());

ItisalsopossibletogetallsolutionsinalistbyToList().ThiscouldbeusedtoworkwithLinQtoobjectswhichisreallynice.PlQueryand

Copy

ToList()forfurthersamples.

C#

varresults=fromninnewPlQuery("member(A,[a,b,c])"

foreach(varsinresults)

Console.WriteLine(s.A);

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.de

C#SwiPlCsinterface►SbsSW.SwiPlCs►PlEngine

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologPlEngineClass

Thisstaticclassrepresentstheprologengine.

DeclarationSyntaxC# VisualBasic VisualC++

publicstaticclassPlEngine

PublicNotInheritableClassPlEngine

publicrefclassPlEngineabstractsealed

MembersAllMembers Methods Properties

PublicProtected

InstanceStatic

Declared

InheritedIcon Member Description

Initialize(String[])InitialiseSWI-Prolog

ThewritemethodoftheoutputstreamisredirectedtoSbsSW.SwiPlCs.StreamsbeforeInitialize.ThereadmethodoftheinputstreamjustafterInitialize.

IsInitialized Totestiftheprologengineisup.

PlCleanup() Tryacleanupbutitisbuggysearchthewebfor"possibleregressionfrompl-5.4.7topl-5.6.27"toseereasons

PlHalt() StopsthePlEngineandtheprogram

PlThreadAttachEngine()return:referencecountoftheengine

Ifanerroroccurs,-1isreturned.

IfthisPrologisnotcompiledformulti-threading,-2isreturned.

PlThreadDestroyEngine() ReturnsTRUEonsuccessandFALSEifthecallingthreadhasnoengineorthisPrologdoesnotsupportthreads.

PlThreadSelf() ReturnstheintegerPrologidentifierofthe

engineor-1ifthecallingthreadhasnoPrologengine.Thismethodisalsoprovidedinthesingle-threadedversionofSWI-Prolog,whereitreturns-2.

RegisterForeign(Delegate)RegisteraC#callbackmethod

RegisterForeign(String,Delegate)RegisteraC#callbackmethod

RegisterForeign(String,Int32,Delegate)RegisteraC#callbackmethod

RegisterForeign(String,String,Int32,Delegate) RegisteraC#callback

method

SetStreamFunctionRead(PlStreamType,DelegateStreamReadFunction)

TODO

SetStreamFunctionWrite(PlStreamType,DelegateStreamWriteFunction)

Thisisaprimitiveapproachtoentertheoutputfromastream.

Copy

Copy

ExamplesAsample

C#

if(!PlEngine.IsInitialized)

{

String[]empty_param={""};

PlEngine.Initialize(empty_param);

//dosomefunnythings...

PlEngine.PlCleanup();

}

//programendshere

Thefollowingsampleshowhowafileisconsultviacomand-lineoptions.

C#

publicvoidDemo_consult_pl_file_by_param()

{

string[]ref_values={"gloria","melanie","ayala"

Console.WriteLine("Demo_consult_pl_file_by_param"

//Buildaprologsourcefile(skipthisstepifyoualreadyhaveone:-)

stringfilename=Path.GetTempFileName();

StreamWritersw=File.CreateText(filename);

sw.WriteLine("father(martin,inka).");

sw.WriteLine("father(uwe,gloria).");

sw.WriteLine("father(uwe,melanie).");

sw.WriteLine("father(uwe,ayala).");

sw.Close();

//buildtheparameterstringtoInitializePlEnginewiththegeneratedfile

String[]param={"-q","-f",filename};

try

{

PlEngine.Initialize(param);

Console.WriteLine("allchild'sfromuwe:");

using(PlQueryq=newPlQuery("father(uwe,Child)"

{

intidx=0;

foreach(PlQueryVariablesvinq.SolutionVariables)

{

Console.WriteLine(v["Child"].ToString());

Assert.AreEqual(ref_values[idx++],v[

}

}

}

catch(PlExceptione)

{

Console.WriteLine(e.MessagePl);

Console.WriteLine(e.Message);

}

finally

{

PlEngine.PlCleanup();

}

}//Demo_consult_pl_file_by_param

InheritanceHierarchyObjectPlEngine

SeeAlsoSbsSW.SwiPlCs.Callback

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlEngine►Initialize(String[])

C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologInitializeMethod(argv)

InitialiseSWI-Prolog

ThewritemethodoftheoutputstreamisredirectedtoSbsSW.SwiPlCs.StreamsbeforeInitialize.ThereadmethodoftheinputstreamjustafterInitialize.

DeclarationSyntaxC# VisualBasic VisualC++

publicstaticvoidInitialize(

string[]argv

)

PublicSharedSubInitialize(_

argvAsString()_

)

public:

staticvoidInitialize(

array<String^>^argv

)

Parametersargv(String[])

ForacompleteparameterdescriptionseetheSWI-Prologreferencemanualsection2.4Command-lineoptions.

sampleparameter:

CopyC#

String[]param={"-q","-f",@"some\filename"};

Atthefirstpositionaparameter""isaddedinthismethod.PL_initialise

Remarks

Aknownbug:Initializework*not*asexpectediftherearee.g.GermanumlautsintheparametersSeemarshallinginthesorceNativeMethods.cs

ExamplesForanexampleseePlEngine

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlEngine►IsInitializedC#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-

PrologIsInitializedProperty

Totestiftheprologengineisup.

DeclarationSyntaxC# VisualBasic VisualC++

publicstaticboolIsInitialized{get;}

PublicSharedReadOnlyPropertyIsInitializedAsBoolean

Get

public:

staticpropertyboolIsInitialized{

boolget();

}

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlEngine►PlCleanup()C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-

PrologPlCleanupMethod

Tryacleanupbutitisbuggysearchthewebfor"possibleregressionfrompl-5.4.7topl-5.6.27"toseereasons

DeclarationSyntaxC# VisualBasic VisualC++

publicstaticvoidPlCleanup()

PublicSharedSubPlCleanup

public:

staticvoidPlCleanup()

RemarksUsethismethodonlyatthelastcallbeforerunprogramends

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlEngine►PlHalt()C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologPlHaltMethod

StopsthePlEngineandtheprogram

DeclarationSyntaxC# VisualBasic VisualC++

publicstaticvoidPlHalt()

PublicSharedSubPlHalt

public:

staticvoidPlHalt()

RemarksSWI-Prologcallsinternallypl_cleanupandthanexit(0)

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlEngine►PlThreadAttachEngine()

C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-

PrologPlThreadAttachEngineMethod

return:referencecountoftheengine

Ifanerroroccurs,-1isreturned.

IfthisPrologisnotcompiledformulti-threading,-2isreturned.

DeclarationSyntaxC# VisualBasic VisualC++

publicstaticintPlThreadAttachEngine()

PublicSharedFunctionPlThreadAttachEngineAsInteger

public:

staticintPlThreadAttachEngine()

ReturnValueAreferencecountoftheengine

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlEngine►PlThreadDestroyEngine()

C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-

PrologPlThreadDestroyEngineMethod

ReturnsTRUEonsuccessandFALSEifthecallingthreadhasnoengineorthisPrologdoesnotsupportthreads.

DeclarationSyntaxC# VisualBasic VisualC++

publicstaticboolPlThreadDestroyEngine()

PublicSharedFunctionPlThreadDestroyEngineAsBoolean

public:

staticboolPlThreadDestroyEngine()

ReturnValue

[Missing<returns>documentationfor"M:SbsSW.SwiPlCs.PlEngine.PlThreadDestroyEngine"]

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlEngine►PlThreadSelf()C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-

PrologPlThreadSelfMethod

ReturnstheintegerPrologidentifieroftheengineor-1ifthecallingthreadhasnoPrologengine.Thismethodisalsoprovidedinthesingle-threadedversionofSWI-Prolog,whereitreturns-2.

DeclarationSyntaxC# VisualBasic VisualC++

publicstaticintPlThreadSelf()

PublicSharedFunctionPlThreadSelfAsInteger

public:

staticintPlThreadSelf()

ReturnValue

[Missing<returns>documentationfor"M:SbsSW.SwiPlCs.PlEngine.PlThreadSelf"]

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlEngine►RegisterForeign()

C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-

PrologRegisterForeignMethod

RegisteraC#-functiontoimplementaPrologpredicate.

Afterthiscallreturnssuccessfully,apredicatewithname(astring)andarityarity(aC#int)iscreatedinmodulemodule.

IfmoduleisNULL,thepredicateiscreatedinthemoduleofthecallingcontextorifnocontextispresentinthemoduleuser.

Remarks

Addaadditionalnamespaceby:

usingSbsSW.SwiPlCs.Callback;

ExamplesForanexampleseeDelegateParameter2andDelegateParameter1.

MembersIcon Member Description

RegisterForeign(Delegate)RegisteraC#callbackmethod

RegisterForeign(String,Delegate) RegisteraC#callbackmethod

RegisterForeign(String,Int32,Delegate) RegisteraC#callbackmethod

RegisterForeign(String,String,Int32,Delegate)

RegisteraC#callbackmethod

SeeAlsoSbsSW.SwiPlCs.Callback

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlEngine►RegisterForeign(Delegate)

C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-

PrologRegisterForeignMethod(method)

RegisteraC#callbackmethod

DeclarationSyntaxC# VisualBasic VisualC++

publicstaticboolRegisterForeign(

Delegatemethod

)

PublicSharedFunctionRegisterForeign(_

methodAsDelegate_

)AsBoolean

public:

staticboolRegisterForeign(

Delegate^method

)

Parametersmethod(Delegate)

adelegatetoac#methodSbsSW.SwiPlCs.Callback

ReturnValuetrueifregistrationsucceedotherwisefalse

ExamplesForanexampleseeDelegateParameter2andDelegateParameter1.

SeeAlsoSbsSW.SwiPlCs.Callback

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlEngine►RegisterForeign(String,Delegate)

C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-

PrologRegisterForeignMethod(module,method)

RegisteraC#callbackmethod

DeclarationSyntaxC# VisualBasic VisualC++

publicstaticboolRegisterForeign(

stringmodule,

Delegatemethod

)

PublicSharedFunctionRegisterForeign(_

moduleAsString,_

methodAsDelegate_

)AsBoolean

public:

staticboolRegisterForeign(

String^module,

Delegate^method

)

Parametersmodule(String)

thenameofaprologmoduleUsingModules

method(Delegate)adelegatetoac#methodSbsSW.SwiPlCs.Callback

ReturnValuetrueifregistrationsucceedotherwisefalse

ExamplesForanexampleseeDelegateParameter2andDelegateParameter1.

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlEngine►RegisterForeign(String,Int32,Delegate)

C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-

PrologRegisterForeignMethod(name,arity,method)

RegisteraC#callbackmethod

DeclarationSyntaxC# VisualBasic VisualC++

publicstaticboolRegisterForeign(

stringname,

intarity,

Delegatemethod

)

PublicSharedFunctionRegisterForeign(_

nameAsString,_

arityAsInteger,_

methodAsDelegate_

)AsBoolean

public:

staticboolRegisterForeign(

String^name,

intarity,

Delegate^method

)

Parametersname(String)

ThenameofastaticC#method

arity(Int32)Theamountofparameters

method(Delegate)adelegatetoac#methodSbsSW.SwiPlCs.Callback

ReturnValuetrueifregistrationsucceedotherwisefalse

ExamplesForanexampleseeDelegateParameterVarArgs

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlEngine►RegisterForeign(String,String,Int32,Delegate)

C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-

PrologRegisterForeignMethod(module,name,arity,method)

RegisteraC#callbackmethod

DeclarationSyntaxC# VisualBasic VisualC++

publicstaticboolRegisterForeign(

stringmodule,

stringname,

intarity,

Delegatemethod

)

PublicSharedFunctionRegisterForeign(_

moduleAsString,_

nameAsString,_

arityAsInteger,_

methodAsDelegate_

)AsBoolean

public:

staticboolRegisterForeign(

String^module,

String^name,

intarity,

Delegate^method

)

Parametersmodule(String)

Thenameofthemodule(Prologmodulesystem)

name(String)ThenameofastaticC#method

arity(Int32)Theamountofparameters

method(Delegate)adelegatetoac#methodSbsSW.SwiPlCs.Callback

ReturnValuetrueifregistrationsucceedotherwisefalse

ExamplesForanexampleseeDelegateParameterVarArgs

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlEngine►SetStreamFunctionRead(PlStreamType,DelegateStreamReadFunction)

C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-

PrologSetStreamFunctionReadMethod(streamType,function)

TODO

DeclarationSyntaxC# VisualBasic VisualC++

publicstaticvoidSetStreamFunctionRead(

PlStreamTypestreamType,

DelegateStreamReadFunctionfunction

)

PublicSharedSubSetStreamFunctionRead(_

streamTypeAsPlStreamType,_

functionAsDelegateStreamReadFunction_

)

public:

staticvoidSetStreamFunctionRead(

PlStreamTypestreamType,

DelegateStreamReadFunction^function

)

ParametersstreamType(PlStreamType)

DeterminewhichstreamtousePlStreamType

function(DelegateStreamReadFunction)ADelegateStreamReadFunction

Examples

CopyC#

staticstringref_string_read="hello_dotnet_world_����."

staticinternallongSread(IntPtrhandle,System.IntPtrbuffer,

{

strings=ref_string_read+"\n";

byte[]array=System.Text.Encoding.Unicode.GetBytes(s);

System.Runtime.InteropServices.Marshal.Copy(array,

returnarray.Length;

}

[TestMethod]

publicvoidStreamRead()

{

DelegateStreamReadFunctionrf=newDelegateStreamReadFunction(Sread);

PlEngine.SetStreamFunctionRead(PlStreamType.Input,rf);

//NOTE:read/1needsadot('.')attheend

PlQuery.PlCall("assert((test_read(A):-read(A)))"

PlTermt=PlQuery.PlCallQuery("test_read(A)");

Assert.AreEqual(ref_string_read,t.ToString()+"."

}

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlEngine►SetStreamFunctionWrite(PlStreamType,DelegateStreamWriteFunction)

C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-

PrologSetStreamFunctionWriteMethod(streamType,function)

Thisisaprimitiveapproachtoentertheoutputfromastream.

DeclarationSyntaxC# VisualBasic VisualC++

publicstaticvoidSetStreamFunctionWrite(

PlStreamTypestreamType,

DelegateStreamWriteFunctionfunction

)

PublicSharedSubSetStreamFunctionWrite(_

streamTypeAsPlStreamType,_

functionAsDelegateStreamWriteFunction_

)

public:

staticvoidSetStreamFunctionWrite(

PlStreamTypestreamType,

DelegateStreamWriteFunction^function

)

ParametersstreamType(PlStreamType)

DeterminewhichstreamtousePlStreamType

function(DelegateStreamWriteFunction)ADelegateStreamWriteFunction

Examples

CopyC#

staticstringtest_string;

staticlongSwrite(IntPtrhandle,stringbuffer,long

{

strings=buffer.Substring(0,(int)buffersize);

test_string=s;

returnbuffersize;

}

[TestMethod]

publicvoidStreamWrite()

{

//NOTE:theSwritefunctionisonlycalledifyouflushtheoutputorsendanewlinecharacter

stringref_string="Hello.networld����";PlQuery.PlCall("assert((test_write:-writeln('"

DelegateStreamWriteFunctionwf=newDelegateStreamWriteFunction(Swrite);

PlEngine.SetStreamFunctionWrite(PlStreamType.Output,wf);

PlQuery.PlCall("test_write");

Assert.AreEqual(ref_string+"\r\n",test_string);

}

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

C#SwiPlCsinterface►SbsSW.SwiPlCs►PlFrame

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologPlFrameClass

TheclassPlFrameprovidesaninterfacetodiscardunusedterm-referencesaswellasrewindingunifications(data-backtracking).Reclaimingunusedterm-referencesisautomaticallyperformedafteracalltoaC#-definedpredicatehasfinishedandreturnscontroltoProlog.InthisscenarioPlFrameisrarelyofanyuse.

ThisclasscomesintoplayifthetoplevelprogramisdefinedinC#andcallsPrologmultipletimes.Settingupargumentstoaqueryrequiresterm-referencesandusingPlFrameistheonlywaytoreclaimthem.

DeclarationSyntaxC# VisualBasic VisualC++

publicclassPlFrame:IDisposable

PublicClassPlFrame_

ImplementsIDisposable

publicrefclassPlFrame:IDisposable

MembersAllMembers Constructors Methods

PublicProtected

InstanceStatic

Declared

InheritedIcon Member Description

PlFrame() Creatinganinstanceofthisclassmarksallterm-referencescreatedafterwardstobevalidonlyinthe

scopeofthisinstance.

Dispose() ImplementIDisposable.

Equals(Object) DetermineswhetherthespecifiedObjectisequaltothecurrentObject.

(InheritedfromObject.)

Finalize() Reclaimsallterm-referencescreatedafterconstructingtheinstance.

(OverridesObject.Finalize().)

GetHashCode() Servesasahashfunctionforaparticulartype.

(InheritedfromObject.)

GetType() GetstheTypeofthecurrentinstance.

(InheritedfromObject.)

MemberwiseClone() CreatesashallowcopyofthecurrentObject.

(InheritedfromObject.)

Rewind() Discardsallterm-referencesandglobal-stackdatacreatedaswellasundoingallunificationsaftertheinstancewascreated.

ToString() ReturnsaStringthatrepresentsthecurrentObject.

(InheritedfromObject.)

Copy

Copy

Remarksseehttp://www.swi-prolog.org/pldoc/package/pl2cpp.html#sec:8.1

ExamplesAtypicaluseforPlFrameisthedefinitionofC#methodsthatcallPrologandmaybecalledrepeatedlyfromC#.ConsiderthedefinitionofassertWord(),addingafacttoword/1:

C#

voidAssertWord2(stringword)

{

PlFramefr=newPlFrame();

PlTermVav=newPlTermV(1);

av[0]=PlTerm.PlCompound("word",newPlTermV(new

PlQueryq=newPlQuery("assert",av);

q.NextSolution();

q.Dispose();//IMPORTANT!neverforgettofreethequerybeforethePlFrameisclosed

fr.Dispose();

}

alternativelyyoucanuse

C#

voidAssertWord(stringword)

{

using(PlFramefr=newPlFrame())

{

PlTermVav=newPlTermV(1);

av[0]=PlTerm.PlCompound("word",newPlTermV(

using(PlQueryq=newPlQuery("assert",av))

{

q.NextSolution();

}

}

}

Caution:NOTE:inanycaseyouhavetodestroyanyqueryobjectusedinsideaPlFrame

InheritanceHierarchyObjectPlFrame

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlFrame►PlFrame()C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologPlFrameConstructor

Creatinganinstanceofthisclassmarksallterm-referencescreatedafterwardstobevalidonlyinthescopeofthisinstance.

DeclarationSyntaxC# VisualBasic VisualC++

publicPlFrame()

PublicSubNew

public:

PlFrame()

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlFrame►Dispose()C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologDisposeMethod

ImplementIDisposable.

DeclarationSyntaxC# VisualBasic VisualC++

publicvoidDispose()

PublicSubDispose

public:

virtualvoidDispose()sealed

Remarks

Donotmakethismethodvirtual.

Aderivedclassshouldnotbeabletooverridethismethod.

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlFrame►Finalize()C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologFinalizeMethod

Reclaimsallterm-referencescreatedafterconstructingtheinstance.

DeclarationSyntaxC# VisualBasic VisualC++

protectedoverridevoidFinalize()

ProtectedOverridesSubFinalize

protected:

virtualvoidFinalize()override

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlFrame►Rewind()C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologRewindMethod

Discardsallterm-referencesandglobal-stackdatacreatedaswellasundoingallunificationsaftertheinstancewascreated.

DeclarationSyntaxC# VisualBasic VisualC++

publicvoidRewind()

PublicSubRewind

public:

voidRewind()

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

C#SwiPlCsinterface►SbsSW.SwiPlCs►PlQuery

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologPlQueryClass

Thisclassallowsqueriestoprolog.

AquerycanbecreatedbyastringorbyconstructingcompoundtermsseeConstructorsfordetails.

AllresourcesantermscreatedbyaqueryarereclaimedbyDispose().Itisrecommendedtobuildaqueryinausingscope.

TherearefourpossibleopportunitiestoqueryProlog

Querytype DescriptionAstaticcall Toaskprologforaproof.Return

onlytrueorfalse.

APlCallQuery(String) Togetthefirstresultofagoal

ConstructaPlQueryobjectbyastring.

Themostconvenientway.

ConstructaPlQueryobjectbycompoundterms.

Themostflexibleandfast(runtime)way.

ForexamplesseePlQuery(String)andPlQuery(String,PlTermV)

DeclarationSyntaxC# VisualBasic VisualC++

publicclassPlQuery:IDisposable

PublicClassPlQuery_

ImplementsIDisposable

publicrefclassPlQuery:IDisposable

MembersAllMembers Constructors Methods Properties

PublicProtected

InstanceStatic

Declared

InheritedIcon Member Description

PlQuery(String)Withthisconstructoraqueryiscreatedfromastring.

Uppercaseparametersareinterpretedavariablesbutcan'tbenestedinsubterms.IfyouneedavariableinanestedtermusePlQuery(String,PlTermV).Seetheexamplesfordetails.

PlQuery(String,String) locatingthepredicateinthenamedmodule.

PlQuery(String,PlTermV) Createaquerywherenamedefinesthenameofthepredicateandavtheargumentvector.Thearityisdeducedfromav.ThepredicateislocatedinthePrologmoduleuser.

PlQuery(String,String,PlTermV)

locatingthepredicateinthenamedmodule.

Args ProvideaccesstotheArgument

vectorforthequery

Dispose() Performsapplication-definedtasksassociatedwithfreeing,releasing,orresettingunmanagedresources.

Dispose(Boolean) Releaseallresourcesfromthequery

Equals(Object) DetermineswhetherthespecifiedObjectisequaltothecurrentObject.

(InheritedfromObject.)

Finalize() AllowsanObjecttoattempttofreeresourcesandperformothercleanupoperationsbeforetheObjectisreclaimedbygarbagecollection.

(OverridesObject.Finalize().)

GetHashCode() Servesasahashfunctionforaparticulartype.

(InheritedfromObject.)

GetType() GetstheTypeofthecurrentinstance.

(InheritedfromObject.)

MemberwiseClone() CreatesashallowcopyofthecurrentObject.

(InheritedfromObject.)

NextSolution() Providethenextsolutiontothequery.PrologexceptionsaremappedtoC#exceptions.

PlCall(String,PlTermV) Createaquerywherenamedefinesthenameofthepredicateandavtheargumentvector.Thearityisdeducedfromav.ThepredicateislocatedinthePrologmoduleuser.

PlCall(String,String,PlTermV)

AsPlCall(String,PlTermV)butlocatingthepredicateinthenamedmodule.

PlCall(String) Callagoalonce.

PlCallQuery(String)NOTE:willbechangedinthenearfuture.

returnthesolutionofaquerywhichiscalledoncebycallThrowanArgumentExceptionifthereisnoormorethanonevariableinthegoal

PlCallQuery(String,String) AsPlCallQuery(String)butexecutedinthenamedmodule.

Query(PlQuerySwitch)ObtainstatusinformationonthePrologsystem.Theactualargumenttypedependsontheinformationrequired.TheparameterqueryTypedescribeswhatinformationiswanted.

Returningpointersandintegersasalongisbadstyle.Thesignatureofthisfunctionshouldbechanged.

PlQuerySwitch

SolutionsEnumeratethesolutions.

ForexamplesseePlQuery(String)

SolutionVariablesEnumeratethePlQueryVariablesofonesolution.

ToList()CreateaReadOnlyCollection<T>ofPlQueryVariables.

IfcallingToList()allsolutionsofthequeryaregeneratedandstoredintheCollection.

ToString() ReturnsaStringthatrepresentsthecurrentObject.

(InheritedfromObject.)

VariableNames GetsaCollection<T>ofthevariablenamesifthequerywasbuiltbyastring.

Variables TheListofPlQueryVariablesofthis

PlQuery.

Remarks

ThequerywillbeopenedbyNextSolution()andwillbeclosedifNextSolution()returnfalse.

InheritanceHierarchyObjectPlQuery

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlQuery►PlQuery()C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologPlQueryConstructor

WiththeseconstructorsaPrologquerycanbecreatedbutnotopened.TogettheresultsseeNextSolution()

AQuerycanbecreatedfromastringorbyanameandPlTermV.Thelaterisanativewayandavailableforcompatibility.

IfaQueryiscreatedfromastringrepresentingarbitraryprologtextthehelperclassesPlQueryVarandPlQueryVariablescomesintothegame.InthiscasethemostconvenientwaytogettheresultsistouseSolutionVariablesorToList().

ForexamplesseePlQuery(String).

MembersIcon Member Description

PlQuery(String)Withthisconstructoraqueryiscreatedfromastring.

Uppercaseparametersareinterpretedavariablesbutcan'tbenestedinsubterms.IfyouneedavariableinanestedtermusePlQuery(String,PlTermV).Seetheexamplesfordetails.

PlQuery(String,String) locatingthepredicateinthenamedmodule.

PlQuery(String,PlTermV) Createaquerywherenamedefines

thenameofthepredicateandavtheargumentvector.Thearityisdeducedfromav.ThepredicateislocatedinthePrologmoduleuser.

PlQuery(String,String,PlTermV)

locatingthepredicateinthenamedmodule.

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlQuery►PlQuery(String)C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologPlQueryConstructor(goal)

Withthisconstructoraqueryiscreatedfromastring.

Uppercaseparametersareinterpretedavariablesbutcan'tbenestedinsubterms.IfyouneedavariableinanestedtermusePlQuery(String,PlTermV).Seetheexamplesfordetails.

DeclarationSyntaxC# VisualBasic VisualC++

publicPlQuery(

stringgoal

)

PublicSubNew(_

goalAsString_

)

public:

PlQuery(

String^goal

)

Parametersgoal(String)

Astringforaprologquery

RemarksMuddyWaterssang:"I'ambuildforcomfort,Iain'tbuildforspeed"

Examples

Copy

Copy

Copy

C#

publicvoidqueryStringForeach()

{

stringmm="abc";

PlQueryq=newPlQuery("member(A,[a,b,c])");

inti=0;

foreach(PlTermVsinq.Solutions)

{

Assert.AreEqual(mm[i++].ToString(),s[0].ToString());

}

//orwithnamedvariables

i=0;

foreach(PlQueryVariablessinq.SolutionVariables)

{

Assert.AreEqual(mm[i++].ToString(),s["A"].ToString());

}

}

Thissampleshowsaquerywithtwovariables.

C#

publicvoidqueryString2()

{

PlQueryq=newPlQuery("append(A,B,[a,b,c])");

Assert.IsTrue(q.NextSolution());

Assert.AreEqual("[]",q.Args[0].ToString());

Assert.AreEqual("[a,b,c]",q.Args[1].ToString());

Assert.IsTrue(q.NextSolution());

Assert.AreEqual("[a]",q.Args[0].ToString());

Assert.AreEqual("[b,c]",q.Args[1].ToString());

}

Andthesamewithnamedvariables.

C#

publicvoidqueryStringNamed()

{

Copy

Copy

PlQueryq=newPlQuery("append(A,B,[a,b,c])");

Assert.IsTrue(q.NextSolution());

Assert.AreEqual("[]",q.Variables["A"].ToString());

Assert.AreEqual("[a,b,c]",q.Variables["B"].ToString());

Assert.IsTrue(q.NextSolution());

Assert.AreEqual("[a]",q.Variables["A"].ToString());

Assert.AreEqual("[b,c]",q.Variables["B"].ToString());

}

Thissampleshowswhathappensiftheargumentvectorisusedwithcompoundterms.

C#

publicvoidPlCallQueryCompound_string()

{

string[]mm={"comp(aa,aa1)","comp(aa,aa2)",

build_pred();//create:test(comp(X,Y)):-member(Z,[1,2,3]),atomic_list_concat([X,Z],Y).

PlQueryq=newPlQuery("test(comp(aa,X))");

inti=0;

foreach(PlTermVsinq.Solutions)

{

Assert.AreEqual(mm[i++].ToString(),s[0].ToString());

}

}

Andherehowtogettheresultswithnamedvariableswithcompoundterms.

C#

publicvoidPlCallQueryCompoundNamed_string()

{

string[]mm={"aa1","aa2","aa3"};

build_pred();//create:test(comp(X,Y)):-member(Z,[1,2,3]),atomic_list_concat([X,Z],Y).

PlQueryq=newPlQuery("test(comp(aa,X))");

inti=0;

foreach(PlQueryVariablesvinq.SolutionVariables)

{

Assert.AreEqual(mm[i++].ToString(),v["X"].ToString());

}

}

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlQuery►PlQuery(String,PlTermV)

C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologPlQueryConstructor(name,termV)

Createaquerywherenamedefinesthenameofthepredicateandavtheargumentvector.Thearityisdeducedfromav.ThepredicateislocatedinthePrologmoduleuser.

DeclarationSyntaxC# VisualBasic VisualC++

publicPlQuery(

stringname,

PlTermVtermV

)

PublicSubNew(_

nameAsString,_

termVAsPlTermV_

)

public:

PlQuery(

String^name,

PlTermVtermV

)

Parametersname(String)

thenameofthepredicate

termV(PlTermV)theargumentvectorcontainingtheparameters

Examples

Copy

Thissampleshowsaquerywithacompoundtermasanargument.

C#

publicvoidPlCallQueryCompound_termv()

{

string[]mm={"aa1","aa2","aa3"};

build_pred();//create:test(comp(X,Y)):-member(Z,[1,2,3]),atomic_list_concat([X,Z],Y).

PlTermvar1=PlTerm.PlVar();

PlTermcomp=PlTerm.PlCompound("comp",newPlTerm(

using(PlQueryq=newPlQuery("test",newPlTermV(comp)))

{

inti=0;

foreach(PlTermVsinq.Solutions)

{

Assert.AreEqual(mm[i++].ToString(),var1.ToString());

Assert.AreEqual(comp.ToString(),s[0].ToString());

}

}

}

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlQuery►PlQuery(String,String)

C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologPlQueryConstructor(module,goal)

locatingthepredicateinthenamedmodule.

DeclarationSyntaxC# VisualBasic VisualC++

publicPlQuery(

stringmodule,

stringgoal

)

PublicSubNew(_

moduleAsString,_

goalAsString_

)

public:

PlQuery(

String^module,

String^goal

)

Parametersmodule(String)

locatingthepredicateinthenamedmodule.

goal(String)Astringforaprologquery

Remarks//TODO:mitatom_to_term/3machen

Copy

Copy

Copy

Examples

C#

publicvoidqueryStringForeach()

{

stringmm="abc";

PlQueryq=newPlQuery("member(A,[a,b,c])");

inti=0;

foreach(PlTermVsinq.Solutions)

{

Assert.AreEqual(mm[i++].ToString(),s[0].ToString());

}

//orwithnamedvariables

i=0;

foreach(PlQueryVariablessinq.SolutionVariables)

{

Assert.AreEqual(mm[i++].ToString(),s["A"].ToString());

}

}

Thissampleshowsaquerywithtwovariables.

C#

publicvoidqueryString2()

{

PlQueryq=newPlQuery("append(A,B,[a,b,c])");

Assert.IsTrue(q.NextSolution());

Assert.AreEqual("[]",q.Args[0].ToString());

Assert.AreEqual("[a,b,c]",q.Args[1].ToString());

Assert.IsTrue(q.NextSolution());

Assert.AreEqual("[a]",q.Args[0].ToString());

Assert.AreEqual("[b,c]",q.Args[1].ToString());

}

Andthesamewithnamedvariables.

C#

Copy

Copy

publicvoidqueryStringNamed()

{

PlQueryq=newPlQuery("append(A,B,[a,b,c])");

Assert.IsTrue(q.NextSolution());

Assert.AreEqual("[]",q.Variables["A"].ToString());

Assert.AreEqual("[a,b,c]",q.Variables["B"].ToString());

Assert.IsTrue(q.NextSolution());

Assert.AreEqual("[a]",q.Variables["A"].ToString());

Assert.AreEqual("[b,c]",q.Variables["B"].ToString());

}

Thissampleshowswhathappensiftheargumentvectorisusedwithcompoundterms.

C#

publicvoidPlCallQueryCompound_string()

{

string[]mm={"comp(aa,aa1)","comp(aa,aa2)",

build_pred();//create:test(comp(X,Y)):-member(Z,[1,2,3]),atomic_list_concat([X,Z],Y).

PlQueryq=newPlQuery("test(comp(aa,X))");

inti=0;

foreach(PlTermVsinq.Solutions)

{

Assert.AreEqual(mm[i++].ToString(),s[0].ToString());

}

}

Andherehowtogettheresultswithnamedvariableswithcompoundterms.

C#

publicvoidPlCallQueryCompoundNamed_string()

{

string[]mm={"aa1","aa2","aa3"};

build_pred();//create:test(comp(X,Y)):-member(Z,[1,2,3]),atomic_list_concat([X,Z],Y).

PlQueryq=newPlQuery("test(comp(aa,X))");

inti=0;

foreach(PlQueryVariablesvinq.SolutionVariables)

{

Assert.AreEqual(mm[i++].ToString(),v["X"].ToString());

}

}

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlQuery►PlQuery(String,String,PlTermV)

C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologPlQueryConstructor(module,name,termV)

locatingthepredicateinthenamedmodule.

DeclarationSyntaxC# VisualBasic VisualC++

publicPlQuery(

stringmodule,

stringname,

PlTermVtermV

)

PublicSubNew(_

moduleAsString,_

nameAsString,_

termVAsPlTermV_

)

public:

PlQuery(

String^module,

String^name,

PlTermVtermV

)

Parametersmodule(String)

locatingthepredicateinthenamedmodule.

name(String)thenameofthepredicate

termV(PlTermV)

Copy

theargumentvectorcontainingtheparameters

Examples

Thissampleshowsaquerywithacompoundtermasanargument.

C#

publicvoidPlCallQueryCompound_termv()

{

string[]mm={"aa1","aa2","aa3"};

build_pred();//create:test(comp(X,Y)):-member(Z,[1,2,3]),atomic_list_concat([X,Z],Y).

PlTermvar1=PlTerm.PlVar();

PlTermcomp=PlTerm.PlCompound("comp",newPlTerm(

using(PlQueryq=newPlQuery("test",newPlTermV(comp)))

{

inti=0;

foreach(PlTermVsinq.Solutions)

{

Assert.AreEqual(mm[i++].ToString(),var1.ToString());

Assert.AreEqual(comp.ToString(),s[0].ToString());

}

}

}

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlQuery►ArgsC#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologArgsProperty

ProvideaccesstotheArgumentvectorforthequery

DeclarationSyntaxC# VisualBasic VisualC++

publicPlTermVArgs{get;}

PublicReadOnlyPropertyArgsAsPlTermV

Get

public:

propertyPlTermVArgs{

PlTermVget();

}

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlQuery►Dispose()C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologDisposeMethod

MembersIcon Member Description

Dispose() Performsapplication-definedtasksassociatedwithfreeing,releasing,orresettingunmanagedresources.

Dispose(Boolean) Releaseallresourcesfromthequery

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlQuery►Dispose()C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologDisposeMethod

Performsapplication-definedtasksassociatedwithfreeing,releasing,orresettingunmanagedresources.

DeclarationSyntaxC# VisualBasic VisualC++

publicvoidDispose()

PublicSubDispose

public:

virtualvoidDispose()sealed

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlQuery►Dispose(Boolean)

C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologDisposeMethod(disposing)

Releaseallresourcesfromthequery

DeclarationSyntaxC# VisualBasic VisualC++

protectedvirtualvoidDispose(

booldisposing

)

ProtectedOverridableSubDispose(_

disposingAsBoolean_

)

protected:

virtualvoidDispose(

booldisposing

)

Parametersdisposing(Boolean)

iftrueallisdeleted

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlQuery►Finalize()C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologFinalizeMethod

AllowsanObjecttoattempttofreeresourcesandperformothercleanupoperationsbeforetheObjectisreclaimedbygarbagecollection.

DeclarationSyntaxC# VisualBasic VisualC++

protectedoverridevoidFinalize()

ProtectedOverridesSubFinalize

protected:

virtualvoidFinalize()override

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlQuery►NextSolution()C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-

PrologNextSolutionMethod

Providethenextsolutiontothequery.PrologexceptionsaremappedtoC#exceptions.

DeclarationSyntaxC# VisualBasic VisualC++

publicboolNextSolution()

PublicFunctionNextSolutionAsBoolean

public:

boolNextSolution()

ReturnValuereturntrueifsuccessfulandfalseifthereareno(more)solutions.

Remarks

Ifthequeryiscloseditwillbeopened.Ifthelastsolutionwasgeneratedthequerywillbeclosed.

Ifanexceptionisthrownwhileparsing(open)thequerythe_qidissettozero.

ExceptionsException ConditionPlException IsthrownifSWI-PrologManual

PL_next_solution()returnsfalse

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.de

Assembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

Copy

Copy

SwiPlCsinterface►SbsSW.SwiPlCs►PlQuery►PlCall()C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologPlCallMethod

ThemainpurposeofthestaticPlCallmethodsistocallaprologproveortodosomesiteeffects.Examples

C#

Assert.IsTrue(PlQuery.PlCall("is_list",newPlTerm("[a,b,c,d]"

C#

Assert.IsTrue(PlQuery.PlCall("consult",newPlTerm("some_file_name"

//or

Assert.IsTrue(PlQuery.PlCall("consult('some_file_name')"

MembersIcon Member Description

PlCall(String,PlTermV) Createaquerywherenamedefinesthenameofthepredicateandavtheargumentvector.Thearityisdeducedfromav.ThepredicateislocatedinthePrologmoduleuser.

PlCall(String,String,PlTermV)

AsPlCall(String,PlTermV)butlocatingthepredicateinthenamedmodule.

PlCall(String) Callagoalonce.

byUweLesta,SBS-SoftwaresystemeGmbH

SendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlQuery►PlCall(String)C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologPlCallMethod(goal)

Callagoalonce.

DeclarationSyntaxC# VisualBasic VisualC++

publicstaticboolPlCall(

stringgoal

)

PublicSharedFunctionPlCall(_

goalAsString_

)AsBoolean

public:

staticboolPlCall(

String^goal

)

Parametersgoal(String)

Thecompletegoalasastring

ReturnValueReturntrueorfalseastheresultofNextSolution()orthrowanexception.

Remarks

CreateaPlQueryfromthearguments,generatesthefirstsolutionbyNextSolution()anddestroysthequery.

Examples

Copy

Copy

C#

Assert.IsTrue(PlQuery.PlCall("is_list([a,b,c,d])"));

C#

Assert.IsTrue(PlQuery.PlCall("consult('some_file_name')"

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlQuery►PlCall(String,PlTermV)

C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologPlCallMethod(predicate,args)

Createaquerywherenamedefinesthenameofthepredicateandavtheargumentvector.Thearityisdeducedfromav.ThepredicateislocatedinthePrologmoduleuser.

DeclarationSyntaxC# VisualBasic VisualC++

publicstaticboolPlCall(

stringpredicate,

PlTermVargs

)

PublicSharedFunctionPlCall(_

predicateAsString,_

argsAsPlTermV_

)AsBoolean

public:

staticboolPlCall(

String^predicate,

PlTermVargs

)

Parameterspredicate(String)

definesthenameofthepredicate

args(PlTermV)IsaPlTermVofargumentsforthepredicate

ReturnValue

Copy

ReturntrueorfalseastheresultofNextSolution()orthrowanexception.

Remarks

CreateaPlQueryfromthearguments,generatesthefirstsolutionbyNextSolution()anddestroysthequery.

Examples

Thissampleshowsaquerywithacompoundtermasanargument.

C#

publicvoidPlCallQueryCompound_termv()

{

string[]mm={"aa1","aa2","aa3"};

build_pred();//create:test(comp(X,Y)):-member(Z,[1,2,3]),atomic_list_concat([X,Z],Y).

PlTermvar1=PlTerm.PlVar();

PlTermcomp=PlTerm.PlCompound("comp",newPlTerm(

using(PlQueryq=newPlQuery("test",newPlTermV(comp)))

{

inti=0;

foreach(PlTermVsinq.Solutions)

{

Assert.AreEqual(mm[i++].ToString(),var1.ToString());

Assert.AreEqual(comp.ToString(),s[0].ToString());

}

}

}

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlQuery►PlCall(String,String,PlTermV)

C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologPlCallMethod(module,predicate,args)

AsPlCall(String,PlTermV)butlocatingthepredicateinthenamedmodule.

DeclarationSyntaxC# VisualBasic VisualC++

publicstaticboolPlCall(

stringmodule,

stringpredicate,

PlTermVargs

)

PublicSharedFunctionPlCall(_

moduleAsString,_

predicateAsString,_

argsAsPlTermV_

)AsBoolean

public:

staticboolPlCall(

String^module,

String^predicate,

PlTermVargs

)

Parametersmodule(String)

locatingthepredicateinthenamedmodule.

predicate(String)definesthenameofthepredicate

Copy

args(PlTermV)IsaPlTermVofargumentsforthepredicate

ReturnValueReturntrueorfalseastheresultofNextSolution()orthrowanexception.

Remarks

CreateaPlQueryfromthearguments,generatesthefirstsolutionbyNextSolution()anddestroysthequery.

Examples

Thissampleshowsaquerywithacompoundtermasanargument.

C#

publicvoidPlCallQueryCompound_termv()

{

string[]mm={"aa1","aa2","aa3"};

build_pred();//create:test(comp(X,Y)):-member(Z,[1,2,3]),atomic_list_concat([X,Z],Y).

PlTermvar1=PlTerm.PlVar();

PlTermcomp=PlTerm.PlCompound("comp",newPlTerm(

using(PlQueryq=newPlQuery("test",newPlTermV(comp)))

{

inti=0;

foreach(PlTermVsinq.Solutions)

{

Assert.AreEqual(mm[i++].ToString(),var1.ToString());

Assert.AreEqual(comp.ToString(),s[0].ToString());

}

}

}

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlQuery►PlCallQuery()C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-

PrologPlCallQueryMethod

MembersIcon Member Description

PlCallQuery(String)NOTE:willbechangedinthenearfuture.

returnthesolutionofaquerywhichiscalledoncebycallThrowanArgumentExceptionifthereisnoormorethanonevariableinthegoal

PlCallQuery(String,String)

AsPlCallQuery(String)butexecutedinthenamedmodule.

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlQuery►PlCallQuery(String)

C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-

PrologPlCallQueryMethod(goal)

NOTE:willbechangedinthenearfuture.

returnthesolutionofaquerywhichiscalledoncebycallThrowanArgumentExceptionifthereisnoormorethanonevariableinthegoal

DeclarationSyntaxC# VisualBasic VisualC++

publicstaticPlTermPlCallQuery(

stringgoal

)

PublicSharedFunctionPlCallQuery(_

goalAsString_

)AsPlTerm

public:

staticPlTermPlCallQuery(

String^goal

)

Parametersgoal(String)

agoalwith*one*variable

ReturnValuetheboundvariableofthefirstsolution

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.de

Assembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlQuery►PlCallQuery(String,String)

C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-

PrologPlCallQueryMethod(module,goal)

AsPlCallQuery(String)butexecutedinthenamedmodule.

DeclarationSyntaxC# VisualBasic VisualC++

publicstaticPlTermPlCallQuery(

stringmodule,

stringgoal

)

PublicSharedFunctionPlCallQuery(_

moduleAsString,_

goalAsString_

)AsPlTerm

public:

staticPlTermPlCallQuery(

String^module,

String^goal

)

Parametersmodule(String)

Themodulenameinwhichthequeryisexecuted

goal(String)agoalwith*one*variable

ReturnValuetheboundvariableofthefirstsolution

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlQuery►Query(PlQuerySwitch)

C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologQueryMethod(queryType)

ObtainstatusinformationonthePrologsystem.Theactualargumenttypedependsontheinformationrequired.TheparameterqueryTypedescribeswhatinformationiswanted.

Returningpointersandintegersasalongisbadstyle.Thesignatureofthisfunctionshouldbechanged.

PlQuerySwitch

DeclarationSyntaxC# VisualBasic VisualC++

publicstaticlongQuery(

PlQuerySwitchqueryType

)

PublicSharedFunctionQuery(_

queryTypeAsPlQuerySwitch_

)AsLong

public:

staticlonglongQuery(

PlQuerySwitchqueryType

)

ParametersqueryType(PlQuerySwitch)

APlQuerySwitch.

ReturnValue

Copy

AintdependingonthegivenqueryType

Examples

ThissampleshowshowtogetSWI-Prologsversionnumber

C#

publicvoidPl_query_version()

{

longv=PlQuery.Query(PlQuerySwitch.Version);

Assert.AreEqual(60301,v,"SWI-Prologversionnumber"

}

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlQuery►SolutionsC#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologSolutionsProperty

Enumeratethesolutions.

ForexamplesseePlQuery(String)

DeclarationSyntaxC# VisualBasic VisualC++

publicIEnumerable<PlTermV>Solutions{get;}

PublicReadOnlyPropertySolutionsAsIEnumerable(Of

Get

public:

propertyIEnumerable<PlTermV>^Solutions{

IEnumerable<PlTermV>^get();

}

SeeAlsoNextSolution()Constructors

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

Copy

SwiPlCsinterface►SbsSW.SwiPlCs►PlQuery►SolutionVariablesC#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-

PrologSolutionVariablesProperty

EnumeratethePlQueryVariablesofonesolution.

DeclarationSyntaxC# VisualBasic VisualC++

publicIEnumerable<PlQueryVariables>SolutionVariables

PublicReadOnlyPropertySolutionVariablesAsIEnumerable

Get

public:

propertyIEnumerable<PlQueryVariables^>^SolutionVariables

IEnumerable<PlQueryVariables^>^get();

}

Examples

C#

publicvoidTestCompoundQuery()

{

string[]ref_values={"gloria","melanie","ayala"

using(PlFramefr=newPlFrame())

{

PlQuery.PlCall("assert(father(uwe,gloria))"

PlQuery.PlCall("assert(father(uwe,melanie))"

PlQuery.PlCall("assert(father(uwe,ayala))");

PlQueryplq=newPlQuery("father(P,C),atomic_list_concat([P,'is_father_of',C],L)"

inti=0;

foreach(PlQueryVariablesvarsinplq.SolutionVariables)

{

Assert.AreEqual("uwe",(string)vars["P"]);

Assert.AreEqual(ref_values[i++],(string

}

}

}

SeeAlsoNextSolution()

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

Copy

SwiPlCsinterface►SbsSW.SwiPlCs►PlQuery►ToList()C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologToListMethod

CreateaReadOnlyCollection<T>ofPlQueryVariables.

IfcallingToList()allsolutionsofthequeryaregeneratedandstoredintheCollection.

DeclarationSyntaxC# VisualBasic VisualC++

publicReadOnlyCollection<PlQueryVariables>ToList()

PublicFunctionToListAsReadOnlyCollection(OfPlQueryVariables

public:

ReadOnlyCollection<PlQueryVariables^>^ToList()

ReturnValueAReadOnlyCollectionofPlQueryVariablescontainingallsolutionsofthequery.

Examples

C#

publicvoidTest_multi_goal_ToList()

{

stringmm="abc";

varresults=fromninnewPlQuery("L=[a,b,c],member(A,L)"

selectnew{A=(string)n["A"]};

inti=0;

foreach(vartinresults)

Assert.AreEqual(mm[i++].ToString(),t.A);

}

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlQuery►VariableNamesC#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-

PrologVariableNamesProperty

GetsaCollection<T>ofthevariablenamesifthequerywasbuiltbyastring.

DeclarationSyntaxC# VisualBasic VisualC++

publicCollection<string>VariableNames{get;}

PublicReadOnlyPropertyVariableNamesAsCollection

Get

public:

propertyCollection<String^>^VariableNames{

Collection<String^>^get();

}

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

Copy

SwiPlCsinterface►SbsSW.SwiPlCs►PlQuery►VariablesC#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologVariablesProperty

TheListofPlQueryVariablesofthisPlQuery.

DeclarationSyntaxC# VisualBasic VisualC++

publicPlQueryVariablesVariables{get;}

PublicReadOnlyPropertyVariablesAsPlQueryVariables

Get

public:

propertyPlQueryVariables^Variables{

PlQueryVariables^get();

}

Examples

InthefollowingexampleyouseehowthequeryVariablescanbeusedtosetavariable.

C#

publicvoidTestCompoundQueryWithVariables()

{

string[]ref_values={"x_a","x_b","x_c"};

using(PlFramefr=newPlFrame())

{

PlQueryplq=newPlQuery("member(X,[a,b,c]),atomic_list_concat([P,X],L)"

plq.Variables["P"].Unify("x_");

inti=0;

foreach(PlQueryVariablesvarsinplq.SolutionVariables)

{

Assert.AreEqual("x_",(string)vars["P"]);

Copy

Assert.AreEqual(ref_values[i++],(string

}

}

}

Hereisamorecomplexsamplewherethevariablesoftwoqueriesareconnected.

C#

publicvoidTestCompoundNestedQueryWithVariables()

{

string[]ref_values={"x_a","x_b","x_c"};

string[]ref_values_inner={"a1","a2","b1",

intinner_idx=0;

using(PlFramefr=newPlFrame())

{

PlQueryplq=newPlQuery("member(X,[a,b,c]),atomic_list_concat([P,X],L)"

plq.Variables["P"].Unify("x_");

inti=0;

foreach(PlQueryVariablesvarsinplq.SolutionVariables)

{

Assert.AreEqual("x_",(string)vars["P"]);

Assert.AreEqual(ref_values[i++],(string

PlQueryq=newPlQuery("member(X,[1,2]),atomic_list_concat([P,X],L)"

q.Variables["P"].Unify(plq.Variables["X"

varresults=fromninq.ToList()select

foreach(varvinresults)

{

Assert.AreEqual(ref_values_inner[inner_idx++],v.L);

}

}

}

}

SeeAlsoPlQueryVariables

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

C#SwiPlCsinterface►SbsSW.SwiPlCs►PlQuerySwitch

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-

PrologPlQuerySwitchEnumeration

Flagsthatcontrolfortheforeignpredicateparameters

SWI-PrologManual-9.6.16QueryingProlog.

DeclarationSyntaxC# VisualBasic VisualC++

publicenumPlQuerySwitch

PublicEnumerationPlQuerySwitch

publicenumclassPlQuerySwitch

MembersMember DescriptionNone Thedefaultvalue.

Argc ReturnanintegerholdingthenumberofargumentsgiventoPrologfromUnix.

Argv Returnachar**holdingtheargumentvectorgiventoPrologfromUnix.

GetChar Readcharacterfromterminal.

MaxInteger Returnalong,representingthemaximalintegervaluerepresentedbyaProloginteger.

MinInteger Returnalong,representingtheminimalintegervalue.

Version Returnalong,representingtheversionas10,000×M+100×m+p,whereMisthemajor,mtheminorversionnumberandp

thepatch-level.Forexample,20717means2.7.17

MaxThreads Returnthemaximumnumberofthreadsthatcanbecreatedinthisversion.ReturnvaluesofPL_thread_self()arebetween0andthisnumber.

Encoding ReturnthedefaultstreamencodingofProlog(oftypeIOENC).

UserCpu GetamountofuserCPUtimeoftheprocessinmilliseconds.

SeeAlsoQuery(PlQuerySwitch)

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

C#SwiPlCsinterface►SbsSW.SwiPlCs►PlQueryVar

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-

PrologPlQueryVarClass

RepresentsonevariableofaQueryresult.

DeclarationSyntaxC# VisualBasic VisualC++

publicclassPlQueryVar

PublicClassPlQueryVar

publicrefclassPlQueryVar

MembersAllMembers Methods Properties

PublicProtected

InstanceStatic

Declared

InheritedIcon Member Description

Equals(Object) DetermineswhetherthespecifiedObjectisequaltothecurrentObject.

(InheritedfromObject.)

Finalize() AllowsanObjecttoattempttofreeresourcesandperformothercleanupoperationsbeforetheObjectisreclaimedbygarbagecollection.

(InheritedfromObject.)

GetHashCode() Servesasahashfunctionforaparticulartype.

(InheritedfromObject.)

GetType() GetstheTypeofthecurrentinstance.

(InheritedfromObject.)

MemberwiseClone() CreatesashallowcopyofthecurrentObject.

(InheritedfromObject.)

Name ThenameofavariableinaQuery

ToString() ReturnsaStringthatrepresentsthecurrentObject.

(InheritedfromObject.)

Value TheValue(PlTerm)ofavariableinaQuery

InheritanceHierarchyObjectPlQueryVar

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlQueryVar►NameC#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologNameProperty

ThenameofavariableinaQuery

DeclarationSyntaxC# VisualBasic VisualC++

publicstringName{get;internalset;}

PublicPropertyNameAsString

Get

FriendSet

public:

propertyString^Name{

String^get();

internal:voidset(String^value);

}

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlQueryVar►ValueC#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologValueProperty

TheValue(PlTerm)ofavariableinaQuery

DeclarationSyntaxC# VisualBasic VisualC++

publicPlTermValue{get;internalset;}

PublicPropertyValueAsPlTerm

Get

FriendSet

public:

propertyPlTermValue{

PlTermget();

internal:voidset(PlTermvalue);

}

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlQueryVariablesC#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-

PrologPlQueryVariablesClass

RepresentsthesetvariablesofaQueryifitwascreatedfromastring.

ThisclassisalsousedtorepresenttheresultsofaPlQueryafterToList()orSolutionVariableswascalled.

DeclarationSyntaxC# VisualBasic VisualC++

publicclassPlQueryVariables

PublicClassPlQueryVariables

publicrefclassPlQueryVariables

MembersAllMembers Constructors Methods Properties

PublicProtected

InstanceStatic

Declared

InheritedIcon Member Description

PlQueryVariables() InitializesanewinstanceofthePlQueryVariablesclass

Count Returnsthenumberofelementsinthesequence.(DefinedbyEnumerableofList<PlQueryVar>.)

Copy

Equals(Object) DetermineswhetherthespecifiedObjectisequaltothecurrentObject.

(InheritedfromObject.)

Finalize() AllowsanObjecttoattempttofreeresourcesandperformothercleanupoperationsbeforetheObjectisreclaimedbygarbagecollection.

(InheritedfromObject.)

GetHashCode() Servesasahashfunctionforaparticulartype.

(InheritedfromObject.)

GetType() GetstheTypeofthecurrentinstance.

(InheritedfromObject.)

Item[String] GetsthePlTermofthegivenvariablenameorthrowanArgumentException.

MemberwiseClone() CreatesashallowcopyofthecurrentObject.

(InheritedfromObject.)

ToString() ReturnsaStringthatrepresentsthecurrentObject.

(InheritedfromObject.)

Examples

ThissampleshowsbothVariablesisusedtounifythevariablesoftwonestedqueriesandtheresult

C#

publicvoidTestCompoundNestedQueryWithVariables3()

{

string[]ref_values_inner={"_gap_abc1","_gap_abc2"

intinner_idx=0;

using(PlFramefr=newPlFrame())

{

try

{

PlQueryouter_query=newPlQuery("append(A,B,C),atomic_list_concat(A,A1),atomic_list_concat(B,B1)"

outer_query.Variables["C"].Unify(newPlTerm(

PlQueryinner_query=newPlQuery("member(Count,[1,2]),atomic_list_concat([X,Y,Z,Count],ATOM)"

inner_query.Variables["X"].Unify(outer_query.Variables[

inner_query.Variables["Y"].Unify("_gap_"

inner_query.Variables["Z"].Unify(outer_query.Variables[

foreach(PlQueryVariablesvarsinouter_query.SolutionVariables)

{

varresults=fromnininner_query.ToList()

selectnew{L=n["ATOM"

foreach(varvinresults)

{

Assert.AreEqual(ref_values_inner[inner_idx++],v.L);

}

}

}

catch(Exceptionex)

{

System.Diagnostics.Trace.WriteLine(ex.Message);

Assert.IsFalse(true);

}

}

}

InheritanceHierarchyObjectPlQueryVariables

SeeAlso

Variables

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlQueryVariables►PlQueryVariables()

C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-

PrologPlQueryVariablesConstructor

InitializesanewinstanceofthePlQueryVariablesclass

DeclarationSyntaxC# VisualBasic VisualC++

publicPlQueryVariables()

PublicSubNew

public:

PlQueryVariables()

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlQueryVariables►CountC#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologCountProperty

Returnsthenumberofelementsinthesequence.(DefinedbyEnumerableofList<PlQueryVar>.)

DeclarationSyntaxC# VisualBasic VisualC++

publicintCount{get;}

PublicReadOnlyPropertyCountAsInteger

Get

public:

propertyintCount{

intget();

}

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlQueryVariables►Item[String]

C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologItemProperty(name)

GetsthePlTermofthegivenvariablenameorthrowanArgumentException.

DeclarationSyntaxC# VisualBasic VisualC++

publicPlTermthis[

stringname

]{get;}

PublicReadOnlyDefaultPropertyItem(_

nameAsString_

)AsPlTerm

Get

public:

propertyPlTermdefault[String^name]{

PlTermget(String^name);

}

Parametersname(String)

Thenameofthevariable

ReturnValueThePlTerm(value)ofthevariable

ExceptionsException Condition

ArgumentException Isthrownifthenameisnotthenameofavariable.

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

C#SwiPlCsinterface►SbsSW.SwiPlCs►PlTerm

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologPlTermStructure

ThePlTermstructplaysacentralroleinconversionandoperatingonPrologdata.

PlTermimplementsIComparabletosupportorderingin[!:System.Linq]queriesifPlTermisaList.

CreatingaPlTermcanbedonebytheConstructorsorbythefollowingstaticmethods:

PlVar(),PlTail(),PlCompound,PlString(),PlCodeList(),PlCharList()(seeremarks)

DeclarationSyntaxC# VisualBasic VisualC++

publicstructPlTerm:IComparable,IEnumerable<PlTerm

IEnumerable

PublicStructurePlTerm_

ImplementsIComparable,IEnumerable(OfPlTerm

IEnumerable

publicvalueclassPlTerm:IComparable,

IEnumerable<PlTerm>,IEnumerable

MembersAllMembers Constructors Methods Properties

PublicProtected

InstanceStatic

Declared

Inherited

Icon Member DescriptionPlTerm(String) Createsaterm-referencesholding

aPrologtermrepresentingtext.

PlTerm(Int32) Createsaterm-referencesholdingaPrologintegerrepresentingvalue.

PlTerm(Double) Createsaterm-referencesholdingaPrologfloatrepresentingvalue.

Add(PlTerm) AppendsanelementtoalistbycreatinganewoneandcopyallelementsNoteThisisaslowversionseemymailfromJanfrom2007.11.0614:44

AddList(PlTerm) Appendsalist(PlTail)toalistbycreatinganewoneandcopyallelements

Append(PlTerm) AppendselementtothelistandmakethePlTailreferencepointtothenewvariabletail.IfAisavariable,andthismethodiscalledonitusingtheargument"gnat",alistoftheform[gnat|B]iscreatedandthePlTailobjectnowpointstothenewvariableB.ThismethodreturnsTRUEiftheunificationsucceededandFALSEotherwise.

Noexceptionsaregenerated.

ArityGetthearityofthefunctorifPlTermisacompoundterm.

Close() Unifiesthetermwith[]andreturnstheresultoftheunification.

CompareTo(Object) Comparesthecurrentinstancewithanotherobjectofthesametypeandreturnsanintegerthatindicateswhetherthecurrentinstanceprecedes,follows,oroccursinthesamepositioninthesortorderastheotherobject.

Equality(PlTerm,PlTerm) YieldsTRUEifthePlTermisanatomorstringrepresentingthesametextastheargument,FALSEiftheconversionwassuccessful,butthestringsarenotequalandantype_errorexceptioniftheconversionfailed.

Equality(PlTerm,Int32)

Equality(Int32,PlTerm) YieldsTRUEifthePlTermisanatomorstringrepresentingthesametextastheargument,FALSEiftheconversionwassuccessful,butthestringsarenotequalandantype_errorexceptionifthe

conversionfailed.

Equality(PlTerm,String) YieldsTRUEifthePlTermisanatomorstringrepresentingthesametextastheargument,FALSEiftheconversionwassuccessful,butthestringsarenotequalandantype_errorexceptioniftheconversionfailed.

Equality(String,PlTerm) YieldsTRUEifthePlTermisanatomorstringrepresentingthesametextastheargument,FALSEiftheconversionwassuccessful,butthestringsarenotequalandantype_errorexceptioniftheconversionfailed.

Equals(Object) Indicateswhetherthisinstanceandaspecifiedobjectareequal.

(OverridesValueType.Equals(Object).)

Explicit(PlTermtoString) ConvertsthePrologargumentintoastringwhichimpliesPrologatomsandstringsareconvertedtotherepresentedtextorthrowaPlTypeException.

Explicit(PlTermtoInt32) YieldsaintifthePlTermisaPrologintegerorfloatthatcanbeconvertedwithoutlosstoaint.ThrowsaPlTypeException

exceptionotherwise

Explicit(PlTermtoDouble) YieldsthevalueasaC#doubleifPlTermrepresentsaPrologintegerorfloat.ThrowsaPlTypeExceptionexceptionotherwise.

Finalize() AllowsanObjecttoattempttofreeresourcesandperformothercleanupoperationsbeforetheObjectisreclaimedbygarbagecollection.

(InheritedfromObject.)

GetEnumerator() Returnsanenumeratorthatiteratesthroughthecollection.

GetHashCode() Returnsthehashcodeforthisinstance.

(OverridesValueType.GetHashCode().)

GetType() GetstheTypeofthecurrentinstance.

(InheritedfromObject.)

GreaterThan(PlTerm,PlTerm)

YieldsTRUEifthePlTermisanatomorstringrepresentingthesametextastheargument,FALSEiftheconversionwassuccessful,butthestringsarenotequalandantype_errorexceptioniftheconversionfailed.

GreaterThanOrEqual(PlTerm,PlTerm)

YieldsTRUEifthePlTermisanatomorstringrepresentingthesametextastheargument,FALSEiftheconversionwassuccessful,butthestringsarenotequalandantype_errorexceptioniftheconversionfailed.

Inequality(PlTerm,PlTerm) YieldsTRUEifthePlTermisanatomorstringrepresentingthesametextastheargument,FALSEiftheconversionwassuccessful,butthestringsarenotequalandantype_errorexceptioniftheconversionfailed.

Inequality(PlTerm,Int32) summary

Inequality(Int32,PlTerm) summary

Inequality(PlTerm,String) test

Inequality(String,PlTerm) test

IsAtom ReturntrueifPlTermisanatom.

IsAtomic ReturntrueifPlTermisatomic(notvariableorcompound).

IsCompound ReturntrueifPlTermisacompoundterm.Notethatalistisacompoundterm./2

IsFloat ReturntrueifPlTermisafloat.

IsGround ReturntrueifPlTermisagroundterm.Seealsoground/1.Thisfunctioniscycle-safe.

IsInitialized returnfalseforaPlTermvariablewihichisonlydeclaretedandtruifitisalsoInitialized

IsInteger ReturntrueifPlTermisaninteger.

IsList ReturntrueifPlTermisacompoundtermwithfunctor./2ortheatom[].

IsNumber ReturntrueifPlTermisanintegerorfloat.

IsString ReturntrueifPlTermisastring.

IsVar ReturntrueifPlTermisavariable

Item[Int32]IfPlTermiscompoundandindexisbetween0andArity(including),thenthPlTermisreturned.

Ifposis0thefunctorofthetermisreturned(Foralist'.').

See:PL_get_arg/3

LessThan(PlTerm,PlTerm) YieldsTRUEifthePlTermisanatomorstringrepresentingthesametextastheargument,FALSEiftheconversionwassuccessful,butthestringsarenotequalandantype_errorexceptioniftheconversionfailed.

LessThanOrEqual(PlTerm,PlTerm)

YieldsTRUEifthePlTermisanatomorstringrepresentingthesametextastheargument,FALSEiftheconversionwassuccessful,butthestringsarenotequalandantype_errorexceptioniftheconversionfailed.

MemberwiseClone() CreatesashallowcopyofthecurrentObject.

(InheritedfromObject.)

NameGetaholdingthenameofthefunctorifPlTermisacompoundterm.

NextValue() returnaPlTermboundtothenextelementofthelistPlTailandadvancePlTail.ReturnstheelementonsuccessorafreePlTerm(Variable)ifPlTailrepresentstheemptylist.IfPlTailisneitheralistnortheemptylist,aPlTypeException(type_error)isthrown.

PlCharList(String) CreateaProloglistofone-characteratomsfromaC#-string.

PlCodeList(String) CreateaProloglistofASCIIcodesfroma0-terminatedC-string.

PlCompound(String,PlTermV) Createacompoundtermwiththe

givennamefromthegivenvectorofarguments.SeePlTermVfordetails.

PlCompound(String,PlTerm)Createacompoundtermwiththegivennameantthearguments

PlCompound(String,PlTerm,PlTerm)

Createacompoundtermwiththegivennameantthearguments

PlCompound(String,PlTerm,PlTerm,PlTerm) Createacompoundtermwiththe

givennameantthearguments

PlString(String)

PlString(String,Int32)

PlTail(PlTerm)PlTailisforanalysingandconstructinglists.ItiscalledPlTailasenumeration-stepsmaketheterm-referencefollowthe`tail'ofthelist.

APlTailiscreatedbymakinganewterm-referencepointingtothesameobject.AsPlTailisusedtoenumerateorbuildaProloglist,theinitiallistterm-referencekeepspointingtotheheadofthelist.

PlType GetthePlTypeofaPlTerm.

PlVar() Createsanewinitialisedterm(holdingaPrologvariable).

ToList() ConvertstoastronglytypedReadOnlyCollectionofPlTerm

objectsthatcanbeaccessedbyindex

ToListString() ConvertstoastronglytypedCollectionofstringsthatcanbeaccessedbyindex

ToString()IfPlTermisalistthestringisbuildbycallingToString()foreachelementinthelistseparatedby','andputthebracketsaround'['']'.

(OverridesValueType.ToString().)

ToStringCanonical() ConvertaPlTermtoastringbyPL_get_chars/1withtheCVT_WRITE_CANONICALflag.IfitfailsPL_get_chars/3iscalledagainwithREP_MBflag.

Unify(PlTerm) UnifyaPlTermwithaPlTerm

Unify(String) UnifyaPlTermwithaPlTerm

Remarksstaticmethod DescriptionPlVar() Createsanewinitialisedterm(holdingaProlog

variable).

PlTail(PlTerm) PlTailisforanalysingandconstructinglists.

PlCompound(string) Createcompoundterms.E.g.byparsing(asread/1)thegiventext.

PlString(String) CreateaSWI-Prologstring.

PlCodeList(String) CreateaProloglistofASCIIcodesfroma0-terminatedC-string.

PlCharList(String) CreateaProloglistofone-characteratomsfroma0-terminatedC-string.

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlTerm►PlTerm()C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologPlTermConstructor

AnewPlTermcanbealsocreatedbythestaticmethods:staticmethod DescriptionPlVar() Createsanewinitialisedterm(holdingaProlog

variable).

PlTail(PlTerm) PlTailisforanalysingandconstructinglists.

PlCompound(string) Createcompoundterms.E.g.byparsing(asread/1)thegiventext.

PlString(String) CreateaSWI-Prologstring.

PlCodeList(String) CreateaProloglistofASCIIcodesfroma0-terminatedC-string.

PlCharList(String) CreateaProloglistofone-characteratomsfroma0-terminatedC-string.

MembersIcon Member Description

PlTerm(String) Createsaterm-referencesholdingaPrologtermrepresentingtext.

PlTerm(Int32) Createsaterm-referencesholdingaPrologintegerrepresentingvalue.

PlTerm(Double) Createsaterm-referencesholdingaPrologfloatrepresentingvalue.

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlTerm►PlTerm(Double)C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologPlTermConstructor(value)

Createsaterm-referencesholdingaPrologfloatrepresentingvalue.

DeclarationSyntaxC# VisualBasic VisualC++

publicPlTerm(

doublevalue

)

PublicSubNew(_

valueAsDouble_

)

public:

PlTerm(

doublevalue

)

Parametersvalue(Double)

adoublevalue

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlTerm►PlTerm(Int32)C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologPlTermConstructor(value)

Createsaterm-referencesholdingaPrologintegerrepresentingvalue.

DeclarationSyntaxC# VisualBasic VisualC++

publicPlTerm(

intvalue

)

PublicSubNew(_

valueAsInteger_

)

public:

PlTerm(

intvalue

)

Parametersvalue(Int32)

aintegervalue

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlTerm►PlTerm(String)C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologPlTermConstructor(text)

Createsaterm-referencesholdingaPrologtermrepresentingtext.

DeclarationSyntaxC# VisualBasic VisualC++

publicPlTerm(

stringtext

)

PublicSubNew(_

textAsString_

)

public:

PlTerm(

String^text

)

Parameterstext(String)

thetext

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlTerm►Add(PlTerm)C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologAddMethod(term)

AppendsanelementtoalistbycreatinganewoneandcopyallelementsNoteThisisaslowversionseemymailfromJanfrom2007.11.0614:44

DeclarationSyntaxC# VisualBasic VisualC++

publicboolAdd(

PlTermterm

)

PublicFunctionAdd(_

termAsPlTerm_

)AsBoolean

public:

boolAdd(

PlTermterm

)

Parametersterm(PlTerm)

aclosedlist

ReturnValueTrueifSucceed

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

Copy

SwiPlCsinterface►SbsSW.SwiPlCs►PlTerm►AddList(PlTerm)C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologAddListMethod(listToAppend)

Appendsalist(PlTail)toalistbycreatinganewoneandcopyallelements

DeclarationSyntaxC# VisualBasic VisualC++

publicboolAddList(

PlTermlistToAppend

)

PublicFunctionAddList(_

listToAppendAsPlTerm_

)AsBoolean

public:

boolAddList(

PlTermlistToAppend

)

ParameterslistToAppend(PlTerm)

aclosedlist

ReturnValueTrueifSucceed

Examples

C#

publicvoidList_Add_list_doc()

{

PlTermt=newPlTerm("[x,y]");

PlTerml=newPlTerm("[a,b]");

Assert.IsTrue(l.IsList);

Assert.IsTrue(l.AddList(t));

Assert.IsTrue(l.IsList);

Assert.AreEqual("[a,b,x,y]",l.ToString());

Assert.AreEqual("a",l.NextValue().ToString());

Assert.AreEqual("b",l.NextValue().ToString());

Assert.AreEqual("[x,y]",l.ToString());

}

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlTerm►Append(PlTerm)C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologAppendMethod(term)

AppendselementtothelistandmakethePlTailreferencepointtothenewvariabletail.IfAisavariable,andthismethodiscalledonitusingtheargument"gnat",alistoftheform[gnat|B]iscreatedandthePlTailobjectnowpointstothenewvariableB.ThismethodreturnsTRUEiftheunificationsucceededandFALSEotherwise.Noexceptionsaregenerated.

DeclarationSyntaxC# VisualBasic VisualC++

publicboolAppend(

PlTermterm

)

PublicFunctionAppend(_

termAsPlTerm_

)AsBoolean

public:

boolAppend(

PlTermterm

)

Parametersterm(PlTerm)

ThePlTermtoappendonthelist.

ReturnValuetrueifsuccessfulotherwisefalse

Examples

CopyC#

publicvoidList_Append()

{

PlTermt=PlTerm.PlVar();

PlTerml=PlTerm.PlTail(t);

Assert.IsTrue(l.Append(newPlTerm("one")),"appendone"

Assert.IsTrue(l.Append(newPlTerm("two")),"appendtwo"

Assert.IsTrue(l.Append(newPlTerm("three")),"appendthree"

Assert.AreEqual(1,l.Close());

Assert.AreEqual(3,list_length(t));

Assert.AreEqual("[one,two,three]",t.ToString());

}

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

C#SwiPlCsinterface►SbsSW.SwiPlCs►PlTerm►Arity

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologArityProperty

GetthearityofthefunctorifPlTermisacompoundterm.

DeclarationSyntaxC# VisualBasic VisualC++

publicintArity{get;}

PublicReadOnlyPropertyArityAsInteger

Get

public:

propertyintArity{

intget();

}

Remarks

ArityandNameareforcompoundtermsonly

ExceptionsException ConditionNotSupportedException Isthrownifthetermisn'tcompound

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlTerm►Close()C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologCloseMethod

Unifiesthetermwith[]andreturnstheresultoftheunification.

DeclarationSyntaxC# VisualBasic VisualC++

publicintClose()

PublicFunctionCloseAsInteger

public:

intClose()

ReturnValue

[Missing<returns>documentationfor"M:SbsSW.SwiPlCs.PlTerm.Close"]

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlTerm►CompareTo(Object)

C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-

PrologCompareToMethod(obj)

Comparesthecurrentinstancewithanotherobjectofthesametypeandreturnsanintegerthatindicateswhetherthecurrentinstanceprecedes,follows,oroccursinthesamepositioninthesortorderastheotherobject.

DeclarationSyntaxC# VisualBasic VisualC++

publicintCompareTo(

Objectobj

)

PublicFunctionCompareTo(_

objAsObject_

)AsInteger

public:

virtualintCompareTo(

Object^obj

)sealed

Parametersobj(Object)

Anobjecttocomparewiththisinstance.

ReturnValueA32-bitsignedintegerthatindicatestherelativeorderoftheobjectsbeingcompared.Thereturnvaluehasthesemeanings:ValueMeaningLessthanzeroThisinstanceislessthanobj.ZeroThisinstanceisequaltoobj.GreaterthanzeroThisinstanceisgreaterthanobj.

ExceptionsException ConditionArgumentException objisnotthesametypeasthisinstance.

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlTerm►Equality()C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologEqualityMethod

MembersIcon Member Description

Equality(PlTerm,PlTerm) YieldsTRUEifthePlTermisanatomorstringrepresentingthesametextastheargument,FALSEiftheconversionwassuccessful,butthestringsarenotequalandantype_errorexceptioniftheconversionfailed.

Equality(PlTerm,Int32)

Equality(Int32,PlTerm) YieldsTRUEifthePlTermisanatomorstringrepresentingthesametextastheargument,FALSEiftheconversionwassuccessful,butthestringsarenotequalandantype_errorexceptioniftheconversionfailed.

Equality(PlTerm,String) YieldsTRUEifthePlTermisanatomorstringrepresentingthesametextastheargument,FALSEiftheconversionwassuccessful,butthestringsarenotequalandantype_errorexceptioniftheconversionfailed.

Equality(String,PlTerm) YieldsTRUEifthePlTermisanatom

orstringrepresentingthesametextastheargument,FALSEiftheconversionwassuccessful,butthestringsarenotequalandantype_errorexceptioniftheconversionfailed.

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlTerm►Equality(PlTerm,PlTerm)

C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologEqualityOperator

YieldsTRUEifthePlTermisanatomorstringrepresentingthesametextastheargument,FALSEiftheconversionwassuccessful,butthestringsarenotequalandantype_errorexceptioniftheconversionfailed.

DeclarationSyntaxC# VisualBasic VisualC++

publicstaticbooloperator==(

PlTermterm1,

PlTermterm2

)

PublicSharedOperator=(_

term1AsPlTerm,_

term2AsPlTerm_

)AsBoolean

public:

staticbooloperator==(

PlTermterm1,

PlTermterm2

)

Parametersterm1(PlTerm)

aPlTerm

term2(PlTerm)aPlTerm

ReturnValue

trueorfalse

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlTerm►Equality(PlTerm,Int32)

C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologEqualityOperator

[Missing<summary>documentationfor"M:SbsSW.SwiPlCs.PlTerm.op_Equality(SbsSW.SwiPlCs.PlTerm,System.Int32)"]

DeclarationSyntaxC# VisualBasic VisualC++

publicstaticbooloperator==(

PlTermterm,

intlng

)

PublicSharedOperator=(_

termAsPlTerm,_

lngAsInteger_

)AsBoolean

public:

staticbooloperator==(

PlTermterm,

intlng

)

Parametersterm(PlTerm)

aPlTerm

lng(Int32)aint

ReturnValue

Abool

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlTerm►Equality(PlTerm,String)

C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologEqualityOperator

YieldsTRUEifthePlTermisanatomorstringrepresentingthesametextastheargument,FALSEiftheconversionwassuccessful,butthestringsarenotequalandantype_errorexceptioniftheconversionfailed.

DeclarationSyntaxC# VisualBasic VisualC++

publicstaticbooloperator==(

PlTermterm,

stringvalue

)

PublicSharedOperator=(_

termAsPlTerm,_

valueAsString_

)AsBoolean

public:

staticbooloperator==(

PlTermterm,

String^value

)

Parametersterm(PlTerm)

[Missing<paramname="term"/>documentationfor"M:SbsSW.SwiPlCs.PlTerm.op_Equality(SbsSW.SwiPlCs.PlTerm,System.String)"]

value(String)

[Missing<paramname="value"/>documentationfor"M:SbsSW.SwiPlCs.PlTerm.op_Equality(SbsSW.SwiPlCs.PlTerm,System.String)"]

ReturnValuetrueorfalse

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlTerm►Equality(Int32,PlTerm)

C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologEqualityOperator

YieldsTRUEifthePlTermisanatomorstringrepresentingthesametextastheargument,FALSEiftheconversionwassuccessful,butthestringsarenotequalandantype_errorexceptioniftheconversionfailed.

DeclarationSyntaxC# VisualBasic VisualC++

publicstaticbooloperator==(

intlng,

PlTermterm

)

PublicSharedOperator=(_

lngAsInteger,_

termAsPlTerm_

)AsBoolean

public:

staticbooloperator==(

intlng,

PlTermterm

)

Parameterslng(Int32)

[Missing<paramname="lng"/>documentationfor"M:SbsSW.SwiPlCs.PlTerm.op_Equality(System.Int32,SbsSW.SwiPlCs.PlTerm)"]

term(PlTerm)

[Missing<paramname="term"/>documentationfor"M:SbsSW.SwiPlCs.PlTerm.op_Equality(System.Int32,SbsSW.SwiPlCs.PlTerm)"]

ReturnValuetrueorfalse

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlTerm►Equality(String,PlTerm)

C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologEqualityOperator

YieldsTRUEifthePlTermisanatomorstringrepresentingthesametextastheargument,FALSEiftheconversionwassuccessful,butthestringsarenotequalandantype_errorexceptioniftheconversionfailed.

DeclarationSyntaxC# VisualBasic VisualC++

publicstaticbooloperator==(

stringvalue,

PlTermterm

)

PublicSharedOperator=(_

valueAsString,_

termAsPlTerm_

)AsBoolean

public:

staticbooloperator==(

String^value,

PlTermterm

)

Parametersvalue(String)

[Missing<paramname="value"/>documentationfor"M:SbsSW.SwiPlCs.PlTerm.op_Equality(System.String,SbsSW.SwiPlCs.PlTerm)"]

term(PlTerm)

[Missing<paramname="term"/>documentationfor"M:SbsSW.SwiPlCs.PlTerm.op_Equality(System.String,SbsSW.SwiPlCs.PlTerm)"]

ReturnValuetrueorfalse

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlTerm►Equals(Object)C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologEqualsMethod(obj)

Indicateswhetherthisinstanceandaspecifiedobjectareequal.

DeclarationSyntaxC# VisualBasic VisualC++

publicoverrideboolEquals(

Objectobj

)

PublicOverridesFunctionEquals(_

objAsObject_

)AsBoolean

public:

virtualboolEquals(

Object^obj

)override

Parametersobj(Object)

Anotherobjecttocompareto.

ReturnValuetrueifobjandthisinstancearethesametypeandrepresentthesamevalue;otherwise,false.

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlTerm►Explicit()C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologExplicitMethod

MembersIcon Member Description

Explicit(PlTermtoString) ConvertsthePrologargumentintoastringwhichimpliesPrologatomsandstringsareconvertedtotherepresentedtextorthrowaPlTypeException.

Explicit(PlTermtoInt32) YieldsaintifthePlTermisaPrologintegerorfloatthatcanbeconvertedwithoutlosstoaint.ThrowsaPlTypeExceptionexceptionotherwise

Explicit(PlTermtoDouble) YieldsthevalueasaC#doubleifPlTermrepresentsaPrologintegerorfloat.ThrowsaPlTypeExceptionexceptionotherwise.

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlTerm►Explicit(PlTermtoString)

C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologExplicitOperator

ConvertsthePrologargumentintoastringwhichimpliesPrologatomsandstringsareconvertedtotherepresentedtextorthrowaPlTypeException.

DeclarationSyntaxC# VisualBasic VisualC++

publicstaticexplicitoperatorstring(

PlTermterm

)

PublicSharedNarrowingOperatorCType(_

termAsPlTerm_

)AsString

staticexplicitoperatorString^(

PlTermterm

)

Parametersterm(PlTerm)

APlTermthatcanbeconvertedtoastring

ReturnValueAC#string

Remarks

ConvertsthePrologargumentusingPL_get_chars()usingtheflagsCVT_ALL|CVT_WRITE|BUF_RING,whichimpliesPrologatomsandstringsareconvertedtotherepresentedtextorthrowaPlTypeException.

Iftheabovecallreturn0PL_get_charsiscalledasecondtimewiththeflagsCVT_ALL|CVT_WRITE|BUF_RING|REP_UTF8.

Allotherdataishandedtowrite/1.

MM23.11.2010:MeinesErachtensnachführtlibpl.REP_MBdiegewünschteKonvertierungnachUNICODE(MultiByte)durch.PasstabernichtzurDoku!

ExceptionsException ConditionPlTypeException ThrowsaPlTypeExceptionexception

PreconditionException IsthrowniftheoperatorisusedonanuninitializedPlTerm

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlTerm►Explicit(PlTermtoDouble)

C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologExplicitOperator

YieldsthevalueasaC#doubleifPlTermrepresentsaPrologintegerorfloat.ThrowsaPlTypeExceptionexceptionotherwise.

DeclarationSyntaxC# VisualBasic VisualC++

publicstaticexplicitoperatordouble(

PlTermterm

)

PublicSharedNarrowingOperatorCType(_

termAsPlTerm_

)AsDouble

staticexplicitoperatordouble(

PlTermterm

)

Parametersterm(PlTerm)

APlTermrepresentsaPrologintegerorfloat

ReturnValueAC#double

ExceptionsException ConditionPlTypeException ThrowsaPlTypeExceptionexceptionif

PlTypeisnotaPlType.PlIntegerora

PlType.PlFloat.

PreconditionException IsthrowniftheoperatorisusedonanuninitializedPlTerm

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlTerm►Explicit(PlTermtoInt32)

C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologExplicitOperator

YieldsaintifthePlTermisaPrologintegerorfloatthatcanbeconvertedwithoutlosstoaint.ThrowsaPlTypeExceptionexceptionotherwise

DeclarationSyntaxC# VisualBasic VisualC++

publicstaticexplicitoperatorint(

PlTermterm

)

PublicSharedNarrowingOperatorCType(_

termAsPlTerm_

)AsInteger

staticexplicitoperatorint(

PlTermterm

)

Parametersterm(PlTerm)

APlTermisaPrologintegerorfloatthatcanbeconvertedwithoutlosstoaint.

ReturnValueAC#int

ExceptionsException ConditionPlTypeException ThrowsaPlTypeExceptionexceptionif

PlTypeisnotaPlType.PlIntegeroraPlType.PlFloat.

PreconditionException IsthrowniftheoperatorisusedonanuninitializedPlTerm

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlTerm►GetEnumerator()C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-

PrologGetEnumeratorMethod

Returnsanenumeratorthatiteratesthroughthecollection.

DeclarationSyntaxC# VisualBasic VisualC++

publicIEnumerator<PlTerm>GetEnumerator()

PublicFunctionGetEnumeratorAsIEnumerator(OfPlTerm

public:

virtualIEnumerator<PlTerm>^GetEnumerator()sealed

ReturnValueASystem.Collections.Generic.IEnumerator<Tthatcanbeusedtoiteratethroughthecollection.

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlTerm►GetHashCode()C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-

PrologGetHashCodeMethod

Returnsthehashcodeforthisinstance.

DeclarationSyntaxC# VisualBasic VisualC++

publicoverrideintGetHashCode()

PublicOverridesFunctionGetHashCodeAsInteger

public:

virtualintGetHashCode()override

ReturnValueA32-bitsignedintegerthatisthehashcodeforthisinstance.

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlTerm►GreaterThan(PlTerm,PlTerm)

C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-

PrologGreaterThanOperator

YieldsTRUEifthePlTermisanatomorstringrepresentingthesametextastheargument,FALSEiftheconversionwassuccessful,butthestringsarenotequalandantype_errorexceptioniftheconversionfailed.

DeclarationSyntaxC# VisualBasic VisualC++

publicstaticbooloperator>(

PlTermterm1,

PlTermterm2

)

PublicSharedOperator>(_

term1AsPlTerm,_

term2AsPlTerm_

)AsBoolean

public:

staticbooloperator>(

PlTermterm1,

PlTermterm2

)

Parametersterm1(PlTerm)

aPlTerm

term2(PlTerm)aPlTerm

ReturnValuetrueorfalse

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlTerm►GreaterThanOrEqual(PlTerm,PlTerm)

C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-

PrologGreaterThanOrEqualOperator

YieldsTRUEifthePlTermisanatomorstringrepresentingthesametextastheargument,FALSEiftheconversionwassuccessful,butthestringsarenotequalandantype_errorexceptioniftheconversionfailed.

DeclarationSyntaxC# VisualBasic VisualC++

publicstaticbooloperator>=(

PlTermterm1,

PlTermterm2

)

PublicSharedOperator>=(_

term1AsPlTerm,_

term2AsPlTerm_

)AsBoolean

public:

staticbooloperator>=(

PlTermterm1,

PlTermterm2

)

Parametersterm1(PlTerm)

aPlTerm

term2(PlTerm)aPlTerm

ReturnValuetrueorfalse

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlTerm►Inequality()C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologInequalityMethod

InequalityMethodoverload

Equality(PlTerm,PlTerm)aEquality(PlTerm,Int32)

MembersIcon Member Description

Inequality(PlTerm,PlTerm) YieldsTRUEifthePlTermisanatomorstringrepresentingthesametextastheargument,FALSEiftheconversionwassuccessful,butthestringsarenotequalandantype_errorexceptioniftheconversionfailed.

Inequality(PlTerm,Int32) summary

Inequality(Int32,PlTerm) summary

Inequality(PlTerm,String) test

Inequality(String,PlTerm) test

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.de

Assembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlTerm►Inequality(PlTerm,PlTerm)

C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologInequalityOperator

YieldsTRUEifthePlTermisanatomorstringrepresentingthesametextastheargument,FALSEiftheconversionwassuccessful,butthestringsarenotequalandantype_errorexceptioniftheconversionfailed.

DeclarationSyntaxC# VisualBasic VisualC++

publicstaticbooloperator!=(

PlTermterm1,

PlTermterm2

)

PublicSharedOperator<>(_

term1AsPlTerm,_

term2AsPlTerm_

)AsBoolean

public:

staticbooloperator!=(

PlTermterm1,

PlTermterm2

)

Parametersterm1(PlTerm)

aPlTerm

term2(PlTerm)aPlTerm

ReturnValue

trueorfalse

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlTerm►Inequality(PlTerm,Int32)

C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologInequalityOperator

summary

DeclarationSyntaxC# VisualBasic VisualC++

publicstaticbooloperator!=(

PlTermterm,

intlng

)

PublicSharedOperator<>(_

termAsPlTerm,_

lngAsInteger_

)AsBoolean

public:

staticbooloperator!=(

PlTermterm,

intlng

)

Parametersterm(PlTerm)

[Missing<paramname="term"/>documentationfor"M:SbsSW.SwiPlCs.PlTerm.op_Inequality(SbsSW.SwiPlCs.PlTerm,System.Int32)"]

lng(Int32)

[Missing<paramname="lng"/>documentationfor"M:SbsSW.SwiPlCs.PlTerm.op_Inequality(SbsSW.SwiPlCs.PlTerm,System.Int32)"]

ReturnValue

[Missing<returns>documentationfor"M:SbsSW.SwiPlCs.PlTerm.op_Inequality(SbsSW.SwiPlCs.PlTerm,System.Int32)"]

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlTerm►Inequality(PlTerm,String)

C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologInequalityOperator

test

DeclarationSyntaxC# VisualBasic VisualC++

publicstaticbooloperator!=(

PlTermterm,

stringvalue

)

PublicSharedOperator<>(_

termAsPlTerm,_

valueAsString_

)AsBoolean

public:

staticbooloperator!=(

PlTermterm,

String^value

)

Parametersterm(PlTerm)

[Missing<paramname="term"/>documentationfor"M:SbsSW.SwiPlCs.PlTerm.op_Inequality(SbsSW.SwiPlCs.PlTerm,System.String)"]

value(String)

[Missing<paramname="value"/>documentationfor"M:SbsSW.SwiPlCs.PlTerm.op_Inequality(SbsSW.SwiPlCs.PlTerm,System.String)"]

ReturnValue

[Missing<returns>documentationfor"M:SbsSW.SwiPlCs.PlTerm.op_Inequality(SbsSW.SwiPlCs.PlTerm,System.String)"]

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlTerm►Inequality(Int32,PlTerm)

C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologInequalityOperator

summary

DeclarationSyntaxC# VisualBasic VisualC++

publicstaticbooloperator!=(

intlng,

PlTermterm

)

PublicSharedOperator<>(_

lngAsInteger,_

termAsPlTerm_

)AsBoolean

public:

staticbooloperator!=(

intlng,

PlTermterm

)

Parameterslng(Int32)

[Missing<paramname="lng"/>documentationfor"M:SbsSW.SwiPlCs.PlTerm.op_Inequality(System.Int32,SbsSW.SwiPlCs.PlTerm)"]

term(PlTerm)

[Missing<paramname="term"/>documentationfor"M:SbsSW.SwiPlCs.PlTerm.op_Inequality(System.Int32,SbsSW.SwiPlCs.PlTerm)"]

ReturnValue

[Missing<returns>documentationfor"M:SbsSW.SwiPlCs.PlTerm.op_Inequality(System.Int32,SbsSW.SwiPlCs.PlTerm)"]

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlTerm►Inequality(String,PlTerm)

C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologInequalityOperator

test

DeclarationSyntaxC# VisualBasic VisualC++

publicstaticbooloperator!=(

stringvalue,

PlTermterm

)

PublicSharedOperator<>(_

valueAsString,_

termAsPlTerm_

)AsBoolean

public:

staticbooloperator!=(

String^value,

PlTermterm

)

Parametersvalue(String)

[Missing<paramname="value"/>documentationfor"M:SbsSW.SwiPlCs.PlTerm.op_Inequality(System.String,SbsSW.SwiPlCs.PlTerm)"]

term(PlTerm)

[Missing<paramname="term"/>documentationfor"M:SbsSW.SwiPlCs.PlTerm.op_Inequality(System.String,SbsSW.SwiPlCs.PlTerm)"]

ReturnValue

[Missing<returns>documentationfor"M:SbsSW.SwiPlCs.PlTerm.op_Inequality(System.String,SbsSW.SwiPlCs.PlTerm)"]

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlTerm►IsAtomC#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologIsAtomProperty

ReturntrueifPlTermisanatom.

DeclarationSyntaxC# VisualBasic VisualC++

publicboolIsAtom{get;}

PublicReadOnlyPropertyIsAtomAsBoolean

Get

public:

propertyboolIsAtom{

boolget();

}

SeeAlsoPlType

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlTerm►IsAtomicC#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologIsAtomicProperty

ReturntrueifPlTermisatomic(notvariableorcompound).

DeclarationSyntaxC# VisualBasic VisualC++

publicboolIsAtomic{get;}

PublicReadOnlyPropertyIsAtomicAsBoolean

Get

public:

propertyboolIsAtomic{

boolget();

}

SeeAlsoPlType

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlTerm►IsCompoundC#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-

PrologIsCompoundProperty

ReturntrueifPlTermisacompoundterm.Notethatalistisacompoundterm./2

DeclarationSyntaxC# VisualBasic VisualC++

publicboolIsCompound{get;}

PublicReadOnlyPropertyIsCompoundAsBoolean

Get

public:

propertyboolIsCompound{

boolget();

}

SeeAlsoPlType

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlTerm►IsFloatC#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologIsFloatProperty

ReturntrueifPlTermisafloat.

DeclarationSyntaxC# VisualBasic VisualC++

publicboolIsFloat{get;}

PublicReadOnlyPropertyIsFloatAsBoolean

Get

public:

propertyboolIsFloat{

boolget();

}

SeeAlsoPlType

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlTerm►IsGroundC#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologIsGroundProperty

ReturntrueifPlTermisagroundterm.Seealsoground/1.Thisfunctioniscycle-safe.

DeclarationSyntaxC# VisualBasic VisualC++

publicboolIsGround{get;}

PublicReadOnlyPropertyIsGroundAsBoolean

Get

public:

propertyboolIsGround{

boolget();

}

SeeAlsoPlType

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlTerm►IsInitializedC#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-

PrologIsInitializedProperty

returnfalseforaPlTermvariablewihichisonlydeclaretedandtruifitisalsoInitialized

DeclarationSyntaxC# VisualBasic VisualC++

publicboolIsInitialized{get;}

PublicReadOnlyPropertyIsInitializedAsBoolean

Get

public:

propertyboolIsInitialized{

boolget();

}

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlTerm►IsIntegerC#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologIsIntegerProperty

ReturntrueifPlTermisaninteger.

DeclarationSyntaxC# VisualBasic VisualC++

publicboolIsInteger{get;}

PublicReadOnlyPropertyIsIntegerAsBoolean

Get

public:

propertyboolIsInteger{

boolget();

}

SeeAlsoPlType

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlTerm►IsListC#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologIsListProperty

ReturntrueifPlTermisacompoundtermwithfunctor./2ortheatom[].

DeclarationSyntaxC# VisualBasic VisualC++

publicboolIsList{get;}

PublicReadOnlyPropertyIsListAsBoolean

Get

public:

propertyboolIsList{

boolget();

}

SeeAlsoPlType

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlTerm►IsNumberC#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologIsNumberProperty

ReturntrueifPlTermisanintegerorfloat.

DeclarationSyntaxC# VisualBasic VisualC++

publicboolIsNumber{get;}

PublicReadOnlyPropertyIsNumberAsBoolean

Get

public:

propertyboolIsNumber{

boolget();

}

SeeAlsoPlType

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlTerm►IsStringC#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologIsStringProperty

ReturntrueifPlTermisastring.

DeclarationSyntaxC# VisualBasic VisualC++

publicboolIsString{get;}

PublicReadOnlyPropertyIsStringAsBoolean

Get

public:

propertyboolIsString{

boolget();

}

SeeAlsoPlType

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

C#SwiPlCsinterface►SbsSW.SwiPlCs►PlTerm►IsVar

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologIsVarProperty

ReturntrueifPlTermisavariable

DeclarationSyntaxC# VisualBasic VisualC++

publicboolIsVar{get;}

PublicReadOnlyPropertyIsVarAsBoolean

Get

public:

propertyboolIsVar{

boolget();

}

SeeAlsoPlType

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlTerm►Item[Int32]C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologItemProperty(pos)

IfPlTermiscompoundandindexisbetween0andArity(including),thenthPlTermisreturned.

Ifposis0thefunctorofthetermisreturned(Foralist'.').

See:PL_get_arg/3

DeclarationSyntaxC# VisualBasic VisualC++

publicPlTermthis[

intpos

]{get;}

PublicReadOnlyDefaultPropertyItem(_

posAsInteger_

)AsPlTerm

Get

public:

propertyPlTermdefault[intpos]{

PlTermget(intpos);

}

Parameterspos(Int32)

ToGetthenthPlTerm

ReturnValueaPlTerm

Copy

Examples

C#

[TestMethod]

publicvoidPlTermIndexer2()

{

PlTermt=PlTerm.PlCompound("foo(bar,x(y))");

Assert.AreEqual("foo",t[0].ToString());

Assert.AreEqual("bar",t[1].ToString());

Assert.AreEqual("x(y)",t[2].ToString());

}

[TestMethod]

publicvoidPlTermIndexer_list1()

{

PlTermt=PlTerm.PlCompound("[a,b,c]");

Assert.AreEqual(".",t[0].ToString());

Assert.AreEqual("a",t[1].ToString());

Assert.AreEqual("[b,c]",t[2].ToString());

}

ExceptionsException ConditionNotSupportedException IsthrownifPlTermisnotofType

PlCompoundseeIsCompound

ArgumentOutOfRangeExceptionIsthrownif(pos<0||pos>=Arity)

InvalidOperationException IsthrownifPL_get_argreturns0.

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlTerm►LessThan(PlTerm,PlTerm)

C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologLessThanOperator

YieldsTRUEifthePlTermisanatomorstringrepresentingthesametextastheargument,FALSEiftheconversionwassuccessful,butthestringsarenotequalandantype_errorexceptioniftheconversionfailed.

DeclarationSyntaxC# VisualBasic VisualC++

publicstaticbooloperator<(

PlTermterm1,

PlTermterm2

)

PublicSharedOperator<(_

term1AsPlTerm,_

term2AsPlTerm_

)AsBoolean

public:

staticbooloperator<(

PlTermterm1,

PlTermterm2

)

Parametersterm1(PlTerm)

aPlTerm

term2(PlTerm)aPlTerm

ReturnValue

trueorfalse

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlTerm►LessThanOrEqual(PlTerm,PlTerm)

C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-

PrologLessThanOrEqualOperator

YieldsTRUEifthePlTermisanatomorstringrepresentingthesametextastheargument,FALSEiftheconversionwassuccessful,butthestringsarenotequalandantype_errorexceptioniftheconversionfailed.

DeclarationSyntaxC# VisualBasic VisualC++

publicstaticbooloperator<=(

PlTermterm1,

PlTermterm2

)

PublicSharedOperator<=(_

term1AsPlTerm,_

term2AsPlTerm_

)AsBoolean

public:

staticbooloperator<=(

PlTermterm1,

PlTermterm2

)

Parametersterm1(PlTerm)

aPlTerm

term2(PlTerm)aPlTerm

ReturnValuetrueorfalse

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlTerm►NameC#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologNameProperty

GetaholdingthenameofthefunctorifPlTermisacompoundterm.

DeclarationSyntaxC# VisualBasic VisualC++

publicstringName{get;}

PublicReadOnlyPropertyNameAsString

Get

public:

propertyString^Name{

String^get();

}

Remarks

ArityandNameareforcompoundtermsonly

ExceptionsException ConditionNotSupportedException Isthrownifthetermisn'tcompound

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

Copy

SwiPlCsinterface►SbsSW.SwiPlCs►PlTerm►NextValue()C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-

PrologNextValueMethod

returnaPlTermboundtothenextelementofthelistPlTailandadvancePlTail.ReturnstheelementonsuccessorafreePlTerm(Variable)ifPlTailrepresentstheemptylist.IfPlTailisneitheralistnortheemptylist,aPlTypeException(type_error)isthrown.

DeclarationSyntaxC# VisualBasic VisualC++

publicPlTermNextValue()

PublicFunctionNextValueAsPlTerm

public:

PlTermNextValue()

ReturnValueTheNextelementinthelistasaPlTermwhichisavariableforthelastelementoranemptylist

Examples

C#

publicvoidList_Add_list_doc()

{

PlTermt=newPlTerm("[x,y]");

PlTerml=newPlTerm("[a,b]");

Assert.IsTrue(l.IsList);

Assert.IsTrue(l.AddList(t));

Assert.IsTrue(l.IsList);

Assert.AreEqual("[a,b,x,y]",l.ToString());

Assert.AreEqual("a",l.NextValue().ToString());

Assert.AreEqual("b",l.NextValue().ToString());

Assert.AreEqual("[x,y]",l.ToString());

}

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlTerm►PlCharList(String)C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-

PrologPlCharListMethod(text)

CreateaProloglistofone-characteratomsfromaC#-string.

DeclarationSyntaxC# VisualBasic VisualC++

publicstaticPlTermPlCharList(

stringtext

)

PublicSharedFunctionPlCharList(_

textAsString_

)AsPlTerm

public:

staticPlTermPlCharList(

String^text

)

Parameterstext(String)

astring

ReturnValueAnewPlTermcontainingaprologlistofcharacter

RemarksCharacterlistsarecomplianttoProlog'satom_chars/2predicate.

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0

(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlTerm►PlCodeList(String)C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-

PrologPlCodeListMethod(text)

CreateaProloglistofASCIIcodesfroma0-terminatedC-string.

DeclarationSyntaxC# VisualBasic VisualC++

publicstaticPlTermPlCodeList(

stringtext

)

PublicSharedFunctionPlCodeList(_

textAsString_

)AsPlTerm

public:

staticPlTermPlCodeList(

String^text

)

Parameterstext(String)

Thetext

ReturnValueanewPlTerm

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlTerm►PlCompound()C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-

PrologPlCompoundMethod

MembersIcon Member Description

PlCompound(String,PlTermV) Createacompoundtermwiththe

givennamefromthegivenvectorofarguments.SeePlTermVfordetails.

PlCompound(String,PlTerm) Createacompoundtermwiththe

givennameantthearguments

PlCompound(String,PlTerm,PlTerm) Createacompoundtermwiththe

givennameantthearguments

PlCompound(String,PlTerm,PlTerm,PlTerm) Createacompoundtermwiththe

givennameantthearguments

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlTerm►PlCompound(String,PlTerm)

C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-

PrologPlCompoundMethod(functor,arg1)

Createacompoundtermwiththegivennameantthearguments

DeclarationSyntaxC# VisualBasic VisualC++

publicstaticPlTermPlCompound(

stringfunctor,

PlTermarg1

)

PublicSharedFunctionPlCompound(_

functorAsString,_

arg1AsPlTerm_

)AsPlTerm

public:

staticPlTermPlCompound(

String^functor,

PlTermarg1

)

Parametersfunctor(String)

Thefunctor(name)ofthecompoundterm

arg1(PlTerm)ThefirstArgumentasaPlTerm

ReturnValueanewPlTerm

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlTerm►PlCompound(String,PlTerm,PlTerm)

C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-

PrologPlCompoundMethod(functor,arg1,arg2)

Createacompoundtermwiththegivennameantthearguments

DeclarationSyntaxC# VisualBasic VisualC++

publicstaticPlTermPlCompound(

stringfunctor,

PlTermarg1,

PlTermarg2

)

PublicSharedFunctionPlCompound(_

functorAsString,_

arg1AsPlTerm,_

arg2AsPlTerm_

)AsPlTerm

public:

staticPlTermPlCompound(

String^functor,

PlTermarg1,

PlTermarg2

)

Parametersfunctor(String)

Thefunctor(name)ofthecompoundterm

arg1(PlTerm)ThefirstArgumentasaPlTerm

arg2(PlTerm)

ThesecondArgumentasaPlTerm

ReturnValueanewPlTerm

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlTerm►PlCompound(String,PlTerm,PlTerm,PlTerm)

C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-

PrologPlCompoundMethod(functor,arg1,arg2,arg3)

Createacompoundtermwiththegivennameantthearguments

DeclarationSyntaxC# VisualBasic VisualC++

publicstaticPlTermPlCompound(

stringfunctor,

PlTermarg1,

PlTermarg2,

PlTermarg3

)

PublicSharedFunctionPlCompound(_

functorAsString,_

arg1AsPlTerm,_

arg2AsPlTerm,_

arg3AsPlTerm_

)AsPlTerm

public:

staticPlTermPlCompound(

String^functor,

PlTermarg1,

PlTermarg2,

PlTermarg3

)

Parametersfunctor(String)

Thefunctor(name)ofthecompoundterm

arg1(PlTerm)ThefirstArgumentasaPlTerm

arg2(PlTerm)ThesecondArgumentasaPlTerm

arg3(PlTerm)ThethirdArgumentasaPlTerm

ReturnValueanewPlTerm

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlTerm►PlCompound(String,PlTermV)

C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-

PrologPlCompoundMethod(functor,args)

Createacompoundtermwiththegivennamefromthegivenvectorofarguments.SeePlTermVfordetails.

DeclarationSyntaxC# VisualBasic VisualC++

publicstaticPlTermPlCompound(

stringfunctor,

PlTermVargs

)

PublicSharedFunctionPlCompound(_

functorAsString,_

argsAsPlTermV_

)AsPlTerm

public:

staticPlTermPlCompound(

String^functor,

PlTermVargs

)

Parametersfunctor(String)

Thefunctor(name)ofthecompoundterm

args(PlTermV)theargumentsasaPlTermV

ReturnValueanewPlTerm

Copy

Examples

TheexamplebelowcreatesthePrologtermhello(world).

C#

PlTermt=PlTerm.PlCompound("hello",newPlTermv("world"

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlTerm►PlString()C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologPlStringMethod

ASWI-Prologstringrepresentsabyte-stringontheglobalstack.It'slifetimeisthesameasforcompoundtermsandotherdatalivingontheglobalstack.Stringsarenotonlyacompoundrepresentationoftextthatisgarbage-collected,butastheycancontain0-bytes,theycanbeusedtocontainarbitraryC-datastructures.

MembersIcon Member Description

PlString(String)

PlString(String,Int32)

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlTerm►PlString(String)C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologPlStringMethod(text)

[Missing<summary>documentationfor"M:SbsSW.SwiPlCs.PlTerm.PlString(System.String)"]

DeclarationSyntaxC# VisualBasic VisualC++

publicstaticPlTermPlString(

stringtext

)

PublicSharedFunctionPlString(_

textAsString_

)AsPlTerm

public:

staticPlTermPlString(

String^text

)

Parameterstext(String)

thestring

ReturnValueanewPlTerm

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlTerm►PlString(String,Int32)

C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologPlStringMethod(text,len)

[Missing<summary>documentationfor"M:SbsSW.SwiPlCs.PlTerm.PlString(System.String,System.Int32)"]

DeclarationSyntaxC# VisualBasic VisualC++

publicstaticPlTermPlString(

stringtext,

intlen

)

PublicSharedFunctionPlString(_

textAsString,_

lenAsInteger_

)AsPlTerm

public:

staticPlTermPlString(

String^text,

intlen

)

Parameterstext(String)

thestring

len(Int32)thelengthofthestring

ReturnValue

anewPlTerm

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlTerm►PlTail(PlTerm)C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologPlTailMethod(list)

PlTailisforanalysingandconstructinglists.ItiscalledPlTailasenumeration-stepsmaketheterm-referencefollowthe`tail'ofthelist.

APlTailiscreatedbymakinganewterm-referencepointingtothesameobject.AsPlTailisusedtoenumerateorbuildaProloglist,theinitiallistterm-referencekeepspointingtotheheadofthelist.

DeclarationSyntaxC# VisualBasic VisualC++

publicstaticPlTermPlTail(

PlTermlist

)

PublicSharedFunctionPlTail(_

listAsPlTerm_

)AsPlTerm

public:

staticPlTermPlTail(

PlTermlist

)

Parameterslist(PlTerm)

TheinitialPlTerm

ReturnValueAPlTermforwhichis_list/1succeed.

Examples

CopyC#

publicvoidList_Append()

{

PlTermt=PlTerm.PlVar();

PlTerml=PlTerm.PlTail(t);

Assert.IsTrue(l.Append(newPlTerm("one")),"appendone"

Assert.IsTrue(l.Append(newPlTerm("two")),"appendtwo"

Assert.IsTrue(l.Append(newPlTerm("three")),"appendthree"

Assert.AreEqual(1,l.Close());

Assert.AreEqual(3,list_length(t));

Assert.AreEqual("[one,two,three]",t.ToString());

}

SeeAlsoAppend(PlTerm)Add(PlTerm)AddList(PlTerm)Close()NextValue()

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlTerm►PlTypeC#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologPlTypeProperty

GetthePlTypeofaPlTerm.

DeclarationSyntaxC# VisualBasic VisualC++

publicPlTypePlType{get;}

PublicReadOnlyPropertyPlTypeAsPlType

Get

public:

propertyPlTypePlType{

PlTypeget();

}

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlTerm►PlVar()C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologPlVarMethod

Createsanewinitialisedterm(holdingaPrologvariable).

DeclarationSyntaxC# VisualBasic VisualC++

publicstaticPlTermPlVar()

PublicSharedFunctionPlVarAsPlTerm

public:

staticPlTermPlVar()

ReturnValueaPlTerm

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlTerm►ToList()C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologToListMethod

ConvertstoastronglytypedReadOnlyCollectionofPlTermobjectsthatcanbeaccessedbyindex

DeclarationSyntaxC# VisualBasic VisualC++

publicReadOnlyCollection<PlTerm>ToList()

PublicFunctionToListAsReadOnlyCollection(OfPlTerm

public:

ReadOnlyCollection<PlTerm>^ToList()

ReturnValueAstronglytypedReadOnlyCollectionofPlTermobjects

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlTerm►ToListString()C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-

PrologToListStringMethod

ConvertstoastronglytypedCollectionofstringsthatcanbeaccessedbyindex

DeclarationSyntaxC# VisualBasic VisualC++

publicCollection<string>ToListString()

PublicFunctionToListStringAsCollection(OfString

public:

Collection<String^>^ToListString()

ReturnValueAstronglytypedstringCollection

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlTerm►ToString()C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologToStringMethod

IfPlTermisalistthestringisbuildbycallingToString()foreachelementinthelistseparatedby','andputthebracketsaround'['']'.

DeclarationSyntaxC# VisualBasic VisualC++

publicoverridestringToString()

PublicOverridesFunctionToStringAsString

public:

virtualString^ToString()override

ReturnValueAstringrepresentingthePlTerm.

SeeAlso[O:string]

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlTerm►ToStringCanonical()

C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-

PrologToStringCanonicalMethod

ConvertaPlTermtoastringbyPL_get_chars/1withtheCVT_WRITE_CANONICALflag.IfitfailsPL_get_chars/3iscalledagainwithREP_MBflag.

DeclarationSyntaxC# VisualBasic VisualC++

publicstringToStringCanonical()

PublicFunctionToStringCanonicalAsString

public:

String^ToStringCanonical()

ReturnValuereturnthestringofaPlTerm

ExceptionsException ConditionPlTypeException ThrowsaPlTypeExceptionif

PL_get_chars/3didn'tsucceeds.

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlTerm►Unify()C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologUnifyMethod

ThismethodsperformsPrologunificationandreturnstrueifsuccessfulandfalseotherwise.Itisequaltotheprolog=/2operator.

SeeUnify(PlTerm)foranexample.

RemarksThismethodsareintroducedforclearseparationbetweenthedestructiveassignmentinC#using=andprologunification.

MembersIcon Member Description

Unify(PlTerm) UnifyaPlTermwithaPlTerm

Unify(String) UnifyaPlTermwithaPlTerm

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

Copy

SwiPlCsinterface►SbsSW.SwiPlCs►PlTerm►Unify(PlTerm)C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologUnifyMethod(term)

UnifyaPlTermwithaPlTerm

DeclarationSyntaxC# VisualBasic VisualC++

publicboolUnify(

PlTermterm

)

PublicFunctionUnify(_

termAsPlTerm_

)AsBoolean

public:

boolUnify(

PlTermterm

)

Parametersterm(PlTerm)

thesecondtermforunification

ReturnValuetrueorfalse

Examples

C#

publicvoidUnifyTermVar_doc()

{

PlTermt1=newPlTerm("x(A,2)");

PlTermt2=newPlTerm("x(1,B)");

Assert.IsTrue(t1.Unify(t2));

Assert.AreEqual("x(1,2)",t1.ToString());

Assert.AreEqual("x(1,2)",t2.ToString());

}

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

Copy

SwiPlCsinterface►SbsSW.SwiPlCs►PlTerm►Unify(String)C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologUnifyMethod(atom)

UnifyaPlTermwithaPlTerm

DeclarationSyntaxC# VisualBasic VisualC++

publicboolUnify(

stringatom

)

PublicFunctionUnify(_

atomAsString_

)AsBoolean

public:

boolUnify(

String^atom

)

Parametersatom(String)

Astringtounifywith

ReturnValuetrueorfalse

Examples

C#

publicvoidUnifyTermVar_doc()

{

PlTermt1=newPlTerm("x(A,2)");

PlTermt2=newPlTerm("x(1,B)");

Assert.IsTrue(t1.Unify(t2));

Assert.AreEqual("x(1,2)",t1.ToString());

Assert.AreEqual("x(1,2)",t2.ToString());

}

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

C#SwiPlCsinterface►SbsSW.SwiPlCs►PlTermV

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologPlTermVStructure

ThisAPIispreliminaryandsubjecttochange.

Thistypeisusedtopasstheargumentstoaforeigndefinedpredicate(seeDelegateParameterVarArgs),constructcompoundterms(seePlCompound(String,PlTermV)andtocreatequeries(seePlQuery).

Theonlyusefulmemberfunctionistheoverloadingof[],providing(0-based)accesstotheelements.Item[Int32]RangecheckingisperformedandraisesaArgumentOutOfRangeExceptionexception.

DeclarationSyntaxC# VisualBasic VisualC++

publicstructPlTermV:IEquatable<PlTermV>

PublicStructurePlTermV_

ImplementsIEquatable(OfPlTermV)

publicvalueclassPlTermV:IEquatable<PlTermV>

MembersAllMembers Constructors Methods Properties

PublicProtected

InstanceStatic

Declared

InheritedIcon Member Description

PlTermV(Int32) CreateavectorofPlTermswithsizeelements

PlTermV(PlTerm) CreateaPlTermVfromthegivenPlTerms.

PlTermV(PlTerm,PlTerm) CreateaPlTermVfromthegivenPlTerms.

PlTermV(PlTerm,PlTerm,PlTerm)

CreateaPlTermVfromthegivenPlTerms.

PlTermV(PlTerm[]) CreateaPlTermVfromthegivenPlTerm[]array.

Equality(PlTermV,PlTermV)

Equals(Object) Indicateswhetherthisinstanceandaspecifiedobjectareequal.

(OverridesValueType.Equals(Object).)

Equals(PlTermV) Indicateswhetherthecurrentobjectisequaltoanotherobjectofthesametype.

Finalize() AllowsanObjecttoattempttofreeresourcesandperformothercleanupoperationsbeforetheObjectisreclaimedbygarbagecollection.

(InheritedfromObject.)

GetHashCode() Returnsthehashcodeforthisinstance.

(OverridesValueType.GetHashCode().)

GetType() GetstheTypeofthecurrentinstance.

(InheritedfromObject.)

Inequality(PlTermV,PlTermV)

Item[Int32] Azerobasedlist

MemberwiseClone() CreatesashallowcopyofthecurrentObject.

(InheritedfromObject.)

Size GetthesizeofaPlTermV

ToString() Returnsthefullyqualifiedtypenameofthisinstance.

(InheritedfromValueType.)

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlTermV►PlTermV()C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologPlTermVConstructor

CreateaPlTermVvectorfromthegivenPlTermparameters

CreateanewvectorwithPlTermaselements

Itcanbecreatedwithsizeelements

or

automaticallyfor1,2or3plTerms

MembersIcon Member Description

PlTermV(Int32) CreateavectorofPlTermswithsizeelements

PlTermV(PlTerm) CreateaPlTermVfromthegivenPlTerms.

PlTermV(PlTerm,PlTerm) CreateaPlTermVfromthegivenPlTerms.

PlTermV(PlTerm,PlTerm,PlTerm)

CreateaPlTermVfromthegivenPlTerms.

PlTermV(PlTerm[]) CreateaPlTermVfromthegivenPlTerm[]array.

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlTermV►PlTermV(PlTerm)C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologPlTermVConstructor(term0)

CreateaPlTermVfromthegivenPlTerms.

DeclarationSyntaxC# VisualBasic VisualC++

publicPlTermV(

PlTermterm0

)

PublicSubNew(_

term0AsPlTerm_

)

public:

PlTermV(

PlTermterm0

)

Parametersterm0(PlTerm)

ThefirstPlTerminthevector.

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlTermV►PlTermV(PlTerm,PlTerm)

C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologPlTermVConstructor(term0,term1)

CreateaPlTermVfromthegivenPlTerms.

DeclarationSyntaxC# VisualBasic VisualC++

publicPlTermV(

PlTermterm0,

PlTermterm1

)

PublicSubNew(_

term0AsPlTerm,_

term1AsPlTerm_

)

public:

PlTermV(

PlTermterm0,

PlTermterm1

)

Parametersterm0(PlTerm)

ThefirstPlTerminthevector.

term1(PlTerm)ThesecondPlTerminthevector.

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0

(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlTermV►PlTermV(PlTerm,PlTerm,PlTerm)

C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologPlTermVConstructor(term0,term1,term2)

CreateaPlTermVfromthegivenPlTerms.

DeclarationSyntaxC# VisualBasic VisualC++

publicPlTermV(

PlTermterm0,

PlTermterm1,

PlTermterm2

)

PublicSubNew(_

term0AsPlTerm,_

term1AsPlTerm,_

term2AsPlTerm_

)

public:

PlTermV(

PlTermterm0,

PlTermterm1,

PlTermterm2

)

Parametersterm0(PlTerm)

ThefirstPlTerminthevector.

term1(PlTerm)ThesecondPlTerminthevector.

term2(PlTerm)

ThethirdPlTerminthevector.

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

Copy

SwiPlCsinterface►SbsSW.SwiPlCs►PlTermV►PlTermV(PlTerm[])

C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologPlTermVConstructor(terms)

CreateaPlTermVfromthegivenPlTerm[]array.

DeclarationSyntaxC# VisualBasic VisualC++

publicPlTermV(

PlTerm[]terms

)

PublicSubNew(_

termsAsPlTerm()_

)

public:

PlTermV(

array<PlTerm>^terms

)

Parametersterms(PlTerm[])

AnarrayofPlTermstobuildthevector.

ExamplesUseofInitializinganArrayinCSharp

C#

PlTermVv=newPlTermV(newPlTerm[]{t1,t2,t3,t4});

byUweLesta,SBS-SoftwaresystemeGmbH

SendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlTermV►PlTermV(Int32)C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologPlTermVConstructor(size)

CreateavectorofPlTermswithsizeelements

DeclarationSyntaxC# VisualBasic VisualC++

publicPlTermV(

intsize

)

PublicSubNew(_

sizeAsInteger_

)

public:

PlTermV(

intsize

)

Parameterssize(Int32)

TheamountofPlTermsinthevector

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlTermV►Equality(PlTermV,PlTermV)

C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologEqualityOperator

[Missing<summary>documentationfor"M:SbsSW.SwiPlCs.PlTermV.op_Equality(SbsSW.SwiPlCs.PlTermV,SbsSW.SwiPlCs.PlTermV)"]

DeclarationSyntaxC# VisualBasic VisualC++

publicstaticbooloperator==(

PlTermVtv1,

PlTermVtv2

)

PublicSharedOperator=(_

tv1AsPlTermV,_

tv2AsPlTermV_

)AsBoolean

public:

staticbooloperator==(

PlTermVtv1,

PlTermVtv2

)

Parameterstv1(PlTermV)

[Missing<paramname="tv1"/>documentationfor"M:SbsSW.SwiPlCs.PlTermV.op_Equality(SbsSW.SwiPlCs.PlTermV,SbsSW.SwiPlCs.PlTermV)"]

tv2(PlTermV)

[Missing<paramname="tv2"/>documentationfor"M:SbsSW.SwiPlCs.PlTermV.op_Equality(SbsSW.SwiPlCs.PlTermV,SbsSW.SwiPlCs.PlTermV)"]

ReturnValue

[Missing<returns>documentationfor"M:SbsSW.SwiPlCs.PlTermV.op_Equality(SbsSW.SwiPlCs.PlTermV,SbsSW.SwiPlCs.PlTermV)"]

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlTermV►Equals()C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologEqualsMethod

MembersIcon Member Description

Equals(Object) Indicateswhetherthisinstanceandaspecifiedobjectareequal.

(OverridesValueType.Equals(Object).)

Equals(PlTermV) Indicateswhetherthecurrentobjectisequaltoanotherobjectofthesametype.

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlTermV►Equals(PlTermV)C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologEqualsMethod(other)

Indicateswhetherthecurrentobjectisequaltoanotherobjectofthesametype.

DeclarationSyntaxC# VisualBasic VisualC++

publicboolEquals(

PlTermVother

)

PublicFunctionEquals(_

otherAsPlTermV_

)AsBoolean

public:

virtualboolEquals(

PlTermVother

)sealed

Parametersother(PlTermV)

Anobjecttocomparewiththisobject.

ReturnValuetrueifthecurrentobjectisequaltotheotherparameter;otherwise,false.

Remarks//TODOcompareeachPlTerminPlTermVnotonlythereferecesinA0

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.de

Assembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlTermV►Equals(Object)C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologEqualsMethod(obj)

Indicateswhetherthisinstanceandaspecifiedobjectareequal.

DeclarationSyntaxC# VisualBasic VisualC++

publicoverrideboolEquals(

Objectobj

)

PublicOverridesFunctionEquals(_

objAsObject_

)AsBoolean

public:

virtualboolEquals(

Object^obj

)override

Parametersobj(Object)

Anotherobjecttocompareto.

ReturnValuetrueifobjandthisinstancearethesametypeandrepresentthesamevalue;otherwise,false.

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlTermV►GetHashCode()C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-

PrologGetHashCodeMethod

Returnsthehashcodeforthisinstance.

DeclarationSyntaxC# VisualBasic VisualC++

publicoverrideintGetHashCode()

PublicOverridesFunctionGetHashCodeAsInteger

public:

virtualintGetHashCode()override

ReturnValueA32-bitsignedintegerthatisthehashcodeforthisinstance.

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlTermV►Inequality(PlTermV,PlTermV)

C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologInequalityOperator

[Missing<summary>documentationfor"M:SbsSW.SwiPlCs.PlTermV.op_Inequality(SbsSW.SwiPlCs.PlTermV,SbsSW.SwiPlCs.PlTermV)"]

DeclarationSyntaxC# VisualBasic VisualC++

publicstaticbooloperator!=(

PlTermVtv1,

PlTermVtv2

)

PublicSharedOperator<>(_

tv1AsPlTermV,_

tv2AsPlTermV_

)AsBoolean

public:

staticbooloperator!=(

PlTermVtv1,

PlTermVtv2

)

Parameterstv1(PlTermV)

[Missing<paramname="tv1"/>documentationfor"M:SbsSW.SwiPlCs.PlTermV.op_Inequality(SbsSW.SwiPlCs.PlTermV,SbsSW.SwiPlCs.PlTermV)"]

tv2(PlTermV)

[Missing<paramname="tv2"/>documentationfor"M:SbsSW.SwiPlCs.PlTermV.op_Inequality(SbsSW.SwiPlCs.PlTermV,SbsSW.SwiPlCs.PlTermV)"]

ReturnValue

[Missing<returns>documentationfor"M:SbsSW.SwiPlCs.PlTermV.op_Inequality(SbsSW.SwiPlCs.PlTermV,SbsSW.SwiPlCs.PlTermV)"]

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlTermV►Item[Int32]C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologItemProperty(index)

Azerobasedlist

DeclarationSyntaxC# VisualBasic VisualC++

publicPlTermthis[

intindex

]{get;set;}

PublicDefaultPropertyItem(_

indexAsInteger_

)AsPlTerm

Get

Set

public:

propertyPlTermdefault[intindex]{

PlTermget(intindex);

voidset(intindex,PlTermvalue);

}

Parametersindex(Int32)

ReturnValueThePlTermforthegivenindex

ExceptionsException ConditionArgumentOutOfRangeExceptionIsthrownif(index<0||index>=Size)

PreconditionException IsthrowniftheoperatorisusedonanuninitializedPlTerm

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs►PlTermV►SizeC#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologSizeProperty

GetthesizeofaPlTermV

DeclarationSyntaxC# VisualBasic VisualC++

publicintSize{get;}

PublicReadOnlyPropertySizeAsInteger

Get

public:

propertyintSize{

intget();

}

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

C#SwiPlCsinterface►SbsSW.SwiPlCs►PlType

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologPlTypeEnumeration

Obtainthetypeofaterm,whichshouldbeatermreturnedbyoneoftheotherinterfacepredicatesorpassedasanargument.ThefunctionreturnsthetypeofthePrologterm.Thetypeidentifiersarelistedbelow.

DeclarationSyntaxC# VisualBasic VisualC++

publicenumPlType

PublicEnumerationPlType

publicenumclassPlType

MembersMember DescriptionPlUnknown 0-PL_UNKNOWN:Undefined

PlVariable 1-PL_VARIABLE:Anunboundvariable.Thevalueoftermassuchisauniqueidentifierforthevariable.

PlAtom 2-PL_ATOM:APrologatom.

PlInteger 3-PL_INTEGER:AProloginteger.

PlFloat 4-PL_FLOAT:APrologfloatingpointnumber.

PlString 5-PL_STRING:APrologstring.

PlTerm 6-PL_TERM:Acompoundterm.Notethatalistisacompoundterm./2.

Remarks

Copy

seePL_term_type(term_t)intheSWI-PrologManual.

ExamplesInthissampleaPrologvariableiscreatedinPlTermtandthePlTypeischeckedbyhisintegerrepresentationandhisname.

C#

PlTermt=PlTerm.PlVar();

Assert.AreEqual(1,(int)t.PlType);

Assert.AreEqual(PlType.PlVariable,t.PlType);

SeeAlsoPlType

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

C#SwiPlCsinterface►SbsSW.SwiPlCs.Callback

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-

PrologSbsSW.SwiPlCs.CallbackNamespace

ThenamespaceSbsSW.SwiPlCs.Callbackprovidesthedelegatestoregister.NETmethodstobecalledfromSWI-Prolog

DeclarationSyntaxC# VisualBasic VisualC++

namespaceSbsSW.SwiPlCs.Callback

NamespaceSbsSW.SwiPlCs.Callback

namespaceSbsSW.SwiPlCs.Callback

TypesAllTypes Enumerations Delegates

Icon Type DescriptionDelegateParameter0

ProvideapredefinedDelegatetoregisteraC#methodtobecalledfromSWI-Prolog

DelegateParameter1ProvideapredefinedDelegatetoregisteraC#methodtobecalledfromSWI-Prolog

DelegateParameter2ProvideapredefinedDelegatetoregisteraC#methodtobecalled

fromSWI-Prolog

DelegateParameter3ProvideapredefinedDelegatetoregisteraC#methodtobecalledfromSWI-Prolog

DelegateParameterBacktrackNOTIMPLEMENTEDYET

Fordetailstoimplementsee9.6.17RegisteringForeignPredicates

seealsoPL_foreign_control

DelegateParameterVarArgsWiththisdelegateyoucanbuildacall-backpredicatewithavariableamountofparameters.

PlForeignSwitches Flagsthatareresponsiblefortheforeignpredicateparameters

RemarksNote:Itisonlypossibletocallstaticmethods

SeeAlsoRegisterForeign(String,Delegate)

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.de

Copy

SwiPlCsinterface►SbsSW.SwiPlCs.Callback►DelegateParameter0

C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-

PrologDelegateParameter0Delegate

ProvideapredefinedDelegatetoregisteraC#methodtobecalledfromSWI-Prolog

DeclarationSyntaxC# VisualBasic VisualC++

publicdelegateboolDelegateParameter0()

PublicDelegateFunctionDelegateParameter0AsBoolean

publicdelegateboolDelegateParameter0()

ReturnValuetrueforsucceedingotherwisefalseforfail

Examples

ThisexampleisforDelegateParameter2andshowshowocallaC#methodwithtwoparameter.

ForothersamplesseethesourcefileCallbackForeigenPredicate.csintheTestSwiPlVS2008testproject.

C#

publicvoidt_in_out()

{

DelegatereplaceDelegate=newDelegateParameter2(atom_replace);

PlEngine.RegisterForeign(replaceDelegate);

for(inti=1;i<10;i++)

{

PlTermVarg=newPlTermV(newPlTerm("test_f"

PlQuery.PlCall("atom_replace",arg);

Assert.AreEqual("test_xx_f",arg[1].ToString(),

}

}

publicstaticboolatom_replace(PlTermatom_in,PlTermatom_out)

{

returnatom_out.Unify(atom_in.ToString().Replace(

}

SeeAlsoRegisterForeign(Delegate)PlEngine()

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

Copy

SwiPlCsinterface►SbsSW.SwiPlCs.Callback►DelegateParameter1

C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-

PrologDelegateParameter1Delegate

ProvideapredefinedDelegatetoregisteraC#methodtobecalledfromSWI-Prolog

DeclarationSyntaxC# VisualBasic VisualC++

publicdelegateboolDelegateParameter1(

PlTermterm

)

PublicDelegateFunctionDelegateParameter1(_

termAsPlTerm_

)AsBoolean

publicdelegateboolDelegateParameter1(

PlTermterm

)

Parametersterm(PlTerm)

ReturnValuetrueforsucceedingotherwisefalseforfail

Examples

SeealsotheexampleinDelegateParameter2.

C#

[TestMethod]

publicvoidt_creating_a_list()

{

Delegated=newDelegateParameter1(create_list);

PlEngine.RegisterForeign(d);

for(inti=1;i<10;i++)

{

PlTermt=PlQuery.PlCallQuery("create_list(L)"

Assert.AreEqual("[a,b,c]",t.ToString(),"create_listfailed!"

}

}

publicstaticboolcreate_list(PlTermlist)

{

returnlist.Unify(newPlTerm("[a,b,c]"));

}

SeeAlsoRegisterForeign(Delegate)PlEngine()

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs.Callback►DelegateParameter2

C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-

PrologDelegateParameter2Delegate

ProvideapredefinedDelegatetoregisteraC#methodtobecalledfromSWI-Prolog

DeclarationSyntaxC# VisualBasic VisualC++

publicdelegateboolDelegateParameter2(

PlTermterm1,

PlTermterm2

)

PublicDelegateFunctionDelegateParameter2(_

term1AsPlTerm,_

term2AsPlTerm_

)AsBoolean

publicdelegateboolDelegateParameter2(

PlTermterm1,

PlTermterm2

)

Parametersterm1(PlTerm)term2(PlTerm)

ReturnValuetrueforsucceedingotherwisefalseforfail

Examples

Copy

ThisexampleisforDelegateParameter2andshowshowocallaC#methodwithtwoparameter.

ForothersamplesseethesourcefileCallbackForeigenPredicate.csintheTestSwiPlVS2008testproject.

C#

publicvoidt_in_out()

{

DelegatereplaceDelegate=newDelegateParameter2(atom_replace);

PlEngine.RegisterForeign(replaceDelegate);

for(inti=1;i<10;i++)

{

PlTermVarg=newPlTermV(newPlTerm("test_f"

PlQuery.PlCall("atom_replace",arg);

Assert.AreEqual("test_xx_f",arg[1].ToString(),

}

}

publicstaticboolatom_replace(PlTermatom_in,PlTermatom_out)

{

returnatom_out.Unify(atom_in.ToString().Replace(

}

SeeAlsoRegisterForeign(Delegate)PlEngine()

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs.Callback►DelegateParameter3

C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-

PrologDelegateParameter3Delegate

ProvideapredefinedDelegatetoregisteraC#methodtobecalledfromSWI-Prolog

DeclarationSyntaxC# VisualBasic VisualC++

publicdelegateboolDelegateParameter3(

PlTermterm1,

PlTermterm2,

PlTermterm3

)

PublicDelegateFunctionDelegateParameter3(_

term1AsPlTerm,_

term2AsPlTerm,_

term3AsPlTerm_

)AsBoolean

publicdelegateboolDelegateParameter3(

PlTermterm1,

PlTermterm2,

PlTermterm3

)

Parametersterm1(PlTerm)term2(PlTerm)term3(PlTerm)

ReturnValue

Copy

trueforsucceedingotherwisefalseforfail

Examples

ThisexampleisforDelegateParameter2andshowshowocallaC#methodwithtwoparameter.

ForothersamplesseethesourcefileCallbackForeigenPredicate.csintheTestSwiPlVS2008testproject.

C#

publicvoidt_in_out()

{

DelegatereplaceDelegate=newDelegateParameter2(atom_replace);

PlEngine.RegisterForeign(replaceDelegate);

for(inti=1;i<10;i++)

{

PlTermVarg=newPlTermV(newPlTerm("test_f"

PlQuery.PlCall("atom_replace",arg);

Assert.AreEqual("test_xx_f",arg[1].ToString(),

}

}

publicstaticboolatom_replace(PlTermatom_in,PlTermatom_out)

{

returnatom_out.Unify(atom_in.ToString().Replace(

}

SeeAlsoRegisterForeign(Delegate)PlEngine()

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs.Callback►DelegateParameterBacktrack

C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-

PrologDelegateParameterBacktrackDelegate

NOTIMPLEMENTEDYET

Fordetailstoimplementsee9.6.17RegisteringForeignPredicates

seealsoPL_foreign_control

DeclarationSyntaxC# VisualBasic VisualC++

publicdelegateintDelegateParameterBacktrack(

PlTermterm1,

PlTermterm2,

IntPtrcontrol

)

PublicDelegateFunctionDelegateParameterBacktrack(_

term1AsPlTerm,_

term2AsPlTerm,_

controlAsIntPtr_

)AsInteger

publicdelegateintDelegateParameterBacktrack(

PlTermterm1,

PlTermterm2,

IntPtrcontrol

)

Parametersterm1(PlTerm)

TODO

term2(PlTerm)TODO

control(IntPtr)TODO

ReturnValueTODO

ExamplesTODO

See"t_backtrack"inTestSwiPl.CallbackForeigenPredicate.cs

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

Copy

SwiPlCsinterface►SbsSW.SwiPlCs.Callback►DelegateParameterVarArgs

C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-

PrologDelegateParameterVarArgsDelegate

Withthisdelegateyoucanbuildacall-backpredicatewithavariableamountofparameters.

DeclarationSyntaxC# VisualBasic VisualC++

publicdelegateboolDelegateParameterVarArgs(

PlTermVtermVector

)

PublicDelegateFunctionDelegateParameterVarArgs(_

termVectorAsPlTermV_

)AsBoolean

publicdelegateboolDelegateParameterVarArgs(

PlTermVtermVector

)

ParameterstermVector(PlTermV)

ThetermVectorrepresentingtheargumentswhichcanbeaccessedbytheindexerofPlTermVseePlTermV.TheamountofparametersisinSize

ReturnValueTrueforsucceedingotherwisefalseforfail

Examples

C#

publicvoidt_varargs()

{

Delegated=newDelegateParameterVarArgs(my_concat_atom);

PlEngine.RegisterForeign("my_concat_atom",4,d);

PlEngine.RegisterForeign("my_concat_atom",7,d);

for(inti=1;i<10;i++)

{

PlTermt=PlQuery.PlCallQuery("my_concat_atom(a,b,c,X)"

Assert.AreEqual("abc",t.ToString(),"my_concat_atomfailed!"

t=PlQuery.PlCallQuery("my_concat_atom(a,b,c,d,e,f,X)"

Assert.AreEqual("abcdef",t.ToString(),"my_concat_atomfailed!"

}

}

publicstaticboolmy_concat_atom(PlTermVterm1)

{

intarity=term1.Size;

stringsRet="";

PlTermterm_out=term1[arity-1];

for(inti=0;i<arity-1;i++)

{

strings=term1.ToString();

sRet+=term1[i].ToString();

}

term_out.Unify(sRet);

returntrue;

}

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs.Callback►PlForeignSwitchesC#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-

PrologPlForeignSwitchesEnumeration

Flagsthatareresponsiblefortheforeignpredicateparameters

DeclarationSyntaxC# VisualBasic VisualC++

[FlagsAttribute]

publicenumPlForeignSwitches

<FlagsAttribute>_

PublicEnumerationPlForeignSwitches

[FlagsAttribute]

publicenumclassPlForeignSwitches

MembersMember DescriptionNone 0-PL_FA_NOTHING:noflags.

NoTrace 1-PL_FA_NOTRACE:Predicatecannotbeseeninthetracer.

Transparent 2-PL_FA_TRANSPARENT:Predicateismoduletransparent.

Nondeterministic 4-PL_FA_NONDETERMINISTIC:Predicateisnon-deterministic.SeealsoPL_retry().

VarArgs 8-PL_FA_VARARGS:(Default)Usealternativecallingconvention.

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.de

Assembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

C#SwiPlCsinterface►SbsSW.SwiPlCs.Exceptions

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-

PrologSbsSW.SwiPlCs.ExceptionsNamespace

ThesearethenamespacecommentsforSbsSW.SwiPlCs.Exceptions.

ThenamespaceSbsSW.SwiPlCs.ExceptionsprovidestheExceptionclassestocatchaprologexceptionseeSWI-PrologManual-4.9ISOcompliantExceptionhandling

PrologexceptionsaremappedtoC#exceptionsusingthesubclassPlExceptionofExceptiontorepresentthePrologexceptionterm.

Alltype-conversionfunctionsoftheinterfaceraiseProlog-compliantexceptions,providingdecenterror-handlingsupportatnoextraworkfortheprogrammer.

Forsomecommonlyusedexceptions,subclassesofPlExceptionhavebeencreatedtoexploitboththeirconstructorsforeasycreationoftheseexceptionsaswellasselectivetrappinginC#.

Currently,thesearePlTypeExceptionandPlDomainException.

DeclarationSyntaxC# VisualBasic VisualC++

namespaceSbsSW.SwiPlCs.Exceptions

NamespaceSbsSW.SwiPlCs.Exceptions

namespaceSbsSW.SwiPlCs.Exceptions

TypesAllTypes Classes

Icon Type Description

PlException ThisclassisthebaseclasstocatchexceptionsthrownbyprologinC#.

PlLibException Thisexceptionisthrownifsomethingintheinterfacewentwrong.

PlTypeException AtypeerrorexpressesthatatermdoesnotsatisfytheexpectedbasicPrologtype.

Remarks

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.de

SwiPlCsinterface►SbsSW.SwiPlCs.Exceptions►PlExceptionC#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-

PrologPlExceptionClass

ThisclassisthebaseclasstocatchexceptionsthrownbyprologinC#.

DeclarationSyntaxC# VisualBasic VisualC++

[SerializableAttribute]

publicclassPlException:Exception,

ISerializable

<SerializableAttribute>_

PublicClassPlException_

InheritsException_

ImplementsISerializable

[SerializableAttribute]

publicrefclassPlException:publicException,

ISerializable

MembersAllMembers Constructors Methods Properties

PublicProtected

InstanceStatic

Declared

InheritedIcon Member Description

PlException() Initializesanewinstanceoftheclass.

PlException(String) Initializesanewinstanceofthe

classwithaspecifiederrormessage.

PlException(String,Exception) Initializesanewinstanceoftheclasswithaspecifiederrormessageandareferencetotheinnerexceptionthatisthecauseofthisexception.

PlException(SerializationInfo,StreamingContext)

Initializesanewinstanceoftheclasswithserializeddata.

PlException(PlTerm)Tocatchaexceptionthrownbyprolog

ForaexampleseePlException

Data Getsacollectionofkey/valuepairsthatprovideadditionaluser-definedinformationabouttheexception.

(InheritedfromException.)

Equals(Object) DetermineswhetherthespecifiedequaltothecurrentObject.

(InheritedfromObject.)

Finalize() AllowsanObjecttoattempttofreeresourcesandperformothercleanupoperationsbeforetheObjectisreclaimedbygarbagecollection.

(InheritedfromObject.)

GetBaseException() Whenoverriddeninaderivedclass,returnstheExceptionthatistherootcause

ofoneormoresubsequentexceptions.

(InheritedfromException.)

GetHashCode() Servesasahashfunctionforaparticulartype.

(InheritedfromObject.)

GetObjectData(SerializationInfo,StreamingContext)

Whenoverriddeninaderivedclass,setstheSerializationInfowithinformationabouttheexception.

(OverridesException.GetObjectData(SerializationInfo,StreamingContext).)

GetType() Getstheruntimetypeofthecurrentinstance.

(InheritedfromException.)

HelpLink Getsorsetsalinktothehelpfileassociatedwiththisexception.

(InheritedfromException.)

HResult GetsorsetsHRESULT,acodednumericalvaluethatisassignedtoaspecificexception.

(InheritedfromException.)

InnerException GetstheExceptioninstancethatcausedthecurrentexception.

(InheritedfromException.)

MemberwiseClone() CreatesashallowcopyofthecurrentObject.

(InheritedfromObject.)

Message Getsamessagethatdescribesthecurrent

exception.

(OverridesException.Message.)

MessagePl providesomtimessomeadditionalinformationabouttheexceptionsreason.

PlThrow() TODO

Source Getsorsetsthenameoftheapplicationortheobjectthatcausestheerror.

(InheritedfromException.)

StackTrace Getsastringrepresentationoftheframesonthecallstackatthetimethecurrentexceptionwasthrown.

(InheritedfromException.)

TargetSite Getsthemethodthatthrowsthecurrentexception.

(InheritedfromException.)

Term GetthePlTermofthisexception.

Throw() TODO

ToString() Theexceptionistranslatedintoamessageasproducedbyprint_message/2.Thecharacterdataisstoredinaring.

(OverridesException.ToString()

Examples

CopyC#

publicvoidprolog_exception_sample()

{

stringexception_text="test_exception";

Assert.IsTrue(PlQuery.PlCall("assert((test_throw:-throw("

try

{

Assert.IsTrue(PlQuery.PlCall("test_throw"));

}

catch(PlExceptionex)

{

Assert.AreEqual(exception_text,ex.Term.ToString());

Assert.AreEqual("Unknownmessage:"+exception_text,ex.Message);

}

}

InheritanceHierarchyObjectException

PlException PlTypeException

SeeAlsoPlTypeExceptionSWI-PrologManual-4.9ISOcompliantExceptionhandling

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs.Exceptions►PlException►PlException()

C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-

PrologPlExceptionConstructor

MembersIcon Member Description

PlException() InitializesanewinstanceoftheExceptionclass.

PlException(String) InitializesanewinstanceoftheExceptionclasswithaspecifiederrormessage.

PlException(String,Exception)

InitializesanewinstanceoftheExceptionclasswithaspecifiederrormessageandareferencetotheinnerexceptionthatisthecauseofthisexception.

PlException(SerializationInfo,StreamingContext)

InitializesanewinstanceoftheExceptionclasswithserializeddata.

PlException(PlTerm)Tocatchaexceptionthrownbyprolog

ForaexampleseePlException.

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs.Exceptions►PlException►PlException()

C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-

PrologPlExceptionConstructor

InitializesanewinstanceoftheExceptionclass.

DeclarationSyntaxC# VisualBasic VisualC++

publicPlException()

PublicSubNew

public:

PlException()

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs.Exceptions►PlException►PlException(PlTerm)

C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-

PrologPlExceptionConstructor(term)

Tocatchaexceptionthrownbyprolog

ForaexampleseePlException.

DeclarationSyntaxC# VisualBasic VisualC++

publicPlException(

PlTermterm

)

PublicSubNew(_

termAsPlTerm_

)

public:

PlException(

PlTermterm

)

Parametersterm(PlTerm)

APlTermcontainingthePrologexception

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs.Exceptions►PlException►PlException(SerializationInfo,StreamingContext)

C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-

PrologPlExceptionConstructor(info,context)

InitializesanewinstanceoftheExceptionclasswithserializeddata.

DeclarationSyntaxC# VisualBasic VisualC++

protectedPlException(

SerializationInfoinfo,

StreamingContextcontext

)

ProtectedSubNew(_

infoAsSerializationInfo,_

contextAsStreamingContext_

)

protected:

PlException(

SerializationInfo^info,

StreamingContextcontext

)

Parametersinfo(SerializationInfo)

TheSerializationInfothatholdstheserializedobjectdataabouttheexceptionbeingthrown.

context(StreamingContext)TheStreamingContextthatcontainscontextualinformationaboutthesourceordestination.

Exceptions

Exception ConditionArgumentNullException Theinfoparameterisnull.

SerializationException TheclassnameisnullorHResultiszero(0).

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs.Exceptions►PlException►PlException(String)

C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-

PrologPlExceptionConstructor(message)

InitializesanewinstanceoftheExceptionclasswithaspecifiederrormessage.

DeclarationSyntaxC# VisualBasic VisualC++

publicPlException(

stringmessage

)

PublicSubNew(_

messageAsString_

)

public:

PlException(

String^message

)

Parametersmessage(String)

Themessagethatdescribestheerror.

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs.Exceptions►PlException►PlException(String,Exception)

C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-

PrologPlExceptionConstructor(message,innerException)

InitializesanewinstanceoftheExceptionclasswithaspecifiederrormessageandareferencetotheinnerexceptionthatisthecauseofthisexception.

DeclarationSyntaxC# VisualBasic VisualC++

publicPlException(

stringmessage,

ExceptioninnerException

)

PublicSubNew(_

messageAsString,_

innerExceptionAsException_

)

public:

PlException(

String^message,

Exception^innerException

)

Parametersmessage(String)

Theerrormessagethatexplainsthereasonfortheexception.

innerException(Exception)Theexceptionthatisthecauseofthecurrentexception,oranullreference(NothinginVisualBasic)ifnoinnerexceptionisspecified.

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs.Exceptions►PlException►GetObjectData(SerializationInfo,StreamingContext)

C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-

PrologGetObjectDataMethod(info,context)

Whenoverriddeninaderivedclass,setstheSerializationInfowithinformationabouttheexception.

DeclarationSyntaxC# VisualBasic VisualC++

publicoverridevoidGetObjectData(

SerializationInfoinfo,

StreamingContextcontext

)

PublicOverridesSubGetObjectData(_

infoAsSerializationInfo,_

contextAsStreamingContext_

)

public:

virtualvoidGetObjectData(

SerializationInfo^info,

StreamingContextcontext

)override

Parametersinfo(SerializationInfo)

TheSerializationInfothatholdstheserializedobjectdataabouttheexceptionbeingthrown.

context(StreamingContext)TheStreamingContextthatcontainscontextualinformationaboutthesourceordestination.

Exceptions

Exception ConditionArgumentNullException Theinfoparameterisanullreference

(NothinginVisualBasic).

SecurityException Thecallerdoesnothavetherequiredpermission.

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs.Exceptions►PlException►Message

C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologMessageProperty

Getsamessagethatdescribesthecurrentexception.

DeclarationSyntaxC# VisualBasic VisualC++

publicoverridestringMessage{get;}

PublicOverridesReadOnlyPropertyMessageAsString

Get

public:

virtualpropertyString^Message{

String^get()override;

}

ReturnValueTheerrormessagethatexplainsthereasonfortheexception,oranemptystring("").

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs.Exceptions►PlException►MessagePl

C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-

PrologMessagePlProperty

providesomtimessomeadditionalinformationabouttheexceptionsreason.

DeclarationSyntaxC# VisualBasic VisualC++

publicstringMessagePl{get;}

PublicReadOnlyPropertyMessagePlAsString

Get

public:

propertyString^MessagePl{

String^get();

}

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs.Exceptions►PlException►PlThrow()

C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologPlThrowMethod

TODO

DeclarationSyntaxC# VisualBasic VisualC++

publicintPlThrow()

PublicFunctionPlThrowAsInteger

public:

intPlThrow()

ReturnValue

[Missing<returns>documentationfor"M:SbsSW.SwiPlCs.Exceptions.PlException.PlThrow"]

RemarksUsedinthePREDICATE()wrappertopasstheexceptiontoProlog.SeePL_raise_exeption().

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs.Exceptions►PlException►Term

C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologTermProperty

GetthePlTermofthisexception.

DeclarationSyntaxC# VisualBasic VisualC++

publicPlTermTerm{get;}

PublicReadOnlyPropertyTermAsPlTerm

Get

public:

propertyPlTermTerm{

PlTermget();

}

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs.Exceptions►PlException►Throw()

C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologThrowMethod

TODO

DeclarationSyntaxC# VisualBasic VisualC++

publicvoidThrow()

PublicSubThrow

public:

voidThrow()

Remarksseehttp://www.swi-prolog.org/packages/pl2cpp.html#cppThrow()

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs.Exceptions►PlException►ToString()

C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologToStringMethod

Theexceptionistranslatedintoamessageasproducedbyprint_message/2.Thecharacterdataisstoredinaring.

DeclarationSyntaxC# VisualBasic VisualC++

publicoverridestringToString()

PublicOverridesFunctionToStringAsString

public:

virtualString^ToString()override

ReturnValue

[Missing<returns>documentationfor"M:SbsSW.SwiPlCs.Exceptions.PlException.ToString"]

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs.Exceptions►PlLibExceptionC#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-

PrologPlLibExceptionClass

Thisexceptionisthrownifsomethingintheinterfacewentwrong.

DeclarationSyntaxC# VisualBasic VisualC++

[SerializableAttribute]

publicclassPlLibException:Exception,

ISerializable

<SerializableAttribute>_

PublicClassPlLibException_

InheritsException_

ImplementsISerializable

[SerializableAttribute]

publicrefclassPlLibException:publicException,

ISerializable

MembersAllMembers Constructors Methods Properties

PublicProtected

InstanceStatic

Declared

InheritedIcon Member Description

PlLibException() Initializesanewinstanceoftheclass.

PlLibException(String) Initializesanewinstanceoftheclasswithaspecifiederrormessage.

PlLibException(String,Exception)

Initializesanewinstanceoftheclasswithaspecifiederrormessageandareferencetotheinnerexceptionthatisthecauseofthisexception.

PlLibException(SerializationInfo,StreamingContext)

Initializesanewinstanceoftheclasswithserializeddata.

Data Getsacollectionofkey/valuepairsthatprovideadditionaluser-definedinformationabouttheexception.

(InheritedfromException.)

Equals(Object) DetermineswhetherthespecifiedequaltothecurrentObject.

(InheritedfromObject.)

Finalize() AllowsanObjecttoattempttofreeresourcesandperformothercleanupoperationsbeforetheObjectisreclaimedbygarbagecollection.

(InheritedfromObject.)

GetBaseException() Whenoverriddeninaderivedclass,returnstheExceptionthatistherootcauseofoneormoresubsequentexceptions.

(InheritedfromException.)

GetHashCode() Servesasahashfunctionforaparticulartype.

(InheritedfromObject.)

GetObjectData(SerializationInfo, Whenoverriddeninaderivedclass,sets

StreamingContext) theSerializationInfowithinformationabouttheexception.

(OverridesException.GetObjectData(SerializationInfo,StreamingContext).)

GetType() Getstheruntimetypeofthecurrentinstance.

(InheritedfromException.)

HelpLink Getsorsetsalinktothehelpfileassociatedwiththisexception.

(InheritedfromException.)

HResult GetsorsetsHRESULT,acodednumericalvaluethatisassignedtoaspecificexception.

(InheritedfromException.)

InnerException GetstheExceptioninstancethatcausedthecurrentexception.

(InheritedfromException.)

MemberwiseClone() CreatesashallowcopyofthecurrentObject.

(InheritedfromObject.)

Message Getsamessagethatdescribesthecurrentexception.

(InheritedfromException.)

Source Getsorsetsthenameoftheapplicationortheobjectthatcausestheerror.

(InheritedfromException.)

StackTrace Getsastringrepresentationoftheframes

onthecallstackatthetimethecurrentexceptionwasthrown.

(InheritedfromException.)

TargetSite Getsthemethodthatthrowsthecurrentexception.

(InheritedfromException.)

ToString() Createsandreturnsastringrepresentationofthecurrentexception.

(InheritedfromException.)

InheritanceHierarchyObjectException

PlLibException

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs.Exceptions►PlLibException►PlLibException()

C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-

PrologPlLibExceptionConstructor

MembersIcon Member Description

PlLibException() InitializesanewinstanceoftheExceptionclass.

PlLibException(String) InitializesanewinstanceoftheExceptionclasswithaspecifiederrormessage.

PlLibException(String,Exception)

InitializesanewinstanceoftheExceptionclasswithaspecifiederrormessageandareferencetotheinnerexceptionthatisthecauseofthisexception.

PlLibException(SerializationInfo,StreamingContext)

InitializesanewinstanceoftheExceptionclasswithserializeddata.

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs.Exceptions►PlLibException►PlLibException()

C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-

PrologPlLibExceptionConstructor

InitializesanewinstanceoftheExceptionclass.

DeclarationSyntaxC# VisualBasic VisualC++

publicPlLibException()

PublicSubNew

public:

PlLibException()

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs.Exceptions►PlLibException►PlLibException(SerializationInfo,StreamingContext)

C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-

PrologPlLibExceptionConstructor(info,context)

InitializesanewinstanceoftheExceptionclasswithserializeddata.

DeclarationSyntaxC# VisualBasic VisualC++

protectedPlLibException(

SerializationInfoinfo,

StreamingContextcontext

)

ProtectedSubNew(_

infoAsSerializationInfo,_

contextAsStreamingContext_

)

protected:

PlLibException(

SerializationInfo^info,

StreamingContextcontext

)

Parametersinfo(SerializationInfo)

TheSerializationInfothatholdstheserializedobjectdataabouttheexceptionbeingthrown.

context(StreamingContext)TheStreamingContextthatcontainscontextualinformationaboutthesourceordestination.

Exceptions

Exception ConditionArgumentNullException Theinfoparameterisnull.

SerializationException TheclassnameisnullorHResultiszero(0).

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs.Exceptions►PlLibException►PlLibException(String)

C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-

PrologPlLibExceptionConstructor(message)

InitializesanewinstanceoftheExceptionclasswithaspecifiederrormessage.

DeclarationSyntaxC# VisualBasic VisualC++

publicPlLibException(

stringmessage

)

PublicSubNew(_

messageAsString_

)

public:

PlLibException(

String^message

)

Parametersmessage(String)

Themessagethatdescribestheerror.

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs.Exceptions►PlLibException►PlLibException(String,Exception)

C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-

PrologPlLibExceptionConstructor(message,innerException)

InitializesanewinstanceoftheExceptionclasswithaspecifiederrormessageandareferencetotheinnerexceptionthatisthecauseofthisexception.

DeclarationSyntaxC# VisualBasic VisualC++

publicPlLibException(

stringmessage,

ExceptioninnerException

)

PublicSubNew(_

messageAsString,_

innerExceptionAsException_

)

public:

PlLibException(

String^message,

Exception^innerException

)

Parametersmessage(String)

Theerrormessagethatexplainsthereasonfortheexception.

innerException(Exception)Theexceptionthatisthecauseofthecurrentexception,oranullreference(NothinginVisualBasic)ifnoinnerexceptionisspecified.

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs.Exceptions►PlLibException►GetObjectData(SerializationInfo,StreamingContext)

C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-

PrologGetObjectDataMethod(info,context)

Whenoverriddeninaderivedclass,setstheSerializationInfowithinformationabouttheexception.

DeclarationSyntaxC# VisualBasic VisualC++

publicoverridevoidGetObjectData(

SerializationInfoinfo,

StreamingContextcontext

)

PublicOverridesSubGetObjectData(_

infoAsSerializationInfo,_

contextAsStreamingContext_

)

public:

virtualvoidGetObjectData(

SerializationInfo^info,

StreamingContextcontext

)override

Parametersinfo(SerializationInfo)

TheSerializationInfothatholdstheserializedobjectdataabouttheexceptionbeingthrown.

context(StreamingContext)TheStreamingContextthatcontainscontextualinformationaboutthesourceordestination.

Exceptions

Exception ConditionArgumentNullException Theinfoparameterisanullreference

(NothinginVisualBasic).

SecurityException Thecallerdoesnothavetherequiredpermission.

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs.Exceptions►PlTypeExceptionC#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-

PrologPlTypeExceptionClass

AtypeerrorexpressesthatatermdoesnotsatisfytheexpectedbasicPrologtype.

DeclarationSyntaxC# VisualBasic VisualC++

[SerializableAttribute]

publicclassPlTypeException:PlException

<SerializableAttribute>_

PublicClassPlTypeException_

InheritsPlException

[SerializableAttribute]

publicrefclassPlTypeException:publicPlException

MembersAllMembers Constructors Methods Properties

PublicProtected

InstanceStatic

Declared

InheritedIcon Member Description

PlTypeException() InitializesanewinstanceoftheExceptionclass.

PlTypeException(String) InitializesanewinstanceoftheExceptionclasswithaspecifiederrormessage.

PlTypeException(String,Exception)

InitializesanewinstanceoftheExceptionclasswithaspecifiederrormessageandareferencetotheinnerexceptionthatisthecauseofthisexception.

PlTypeException(SerializationInfo,StreamingContext)

InitializesanewinstanceoftheExceptionclasswithserializeddata.

PlTypeException(PlTerm)Tocatchaexceptionthrownbyprolog

ForaexampleseePlException.

PlTypeException(String,PlTerm) CreatesanISOstandardPrologerrortermexpressingtheexpectedtypeandactualtermthatdoesnotsatisfythistype.

Data Getsacollectionofkey/valuepairsthatprovideadditionaluser-definedinformationabouttheexception.

(InheritedfromException.)

Equals(Object) DetermineswhetherthespecifiedObjectisequalto

thecurrentObject.

(InheritedfromObject.)

Finalize() AllowsanObjecttoattempttofreeresourcesandperformothercleanupoperationsbeforetheObjectisreclaimedbygarbagecollection.

(InheritedfromObject.)

GetBaseException() Whenoverriddeninaderivedclass,returnstheExceptionthatistherootcauseofoneormoresubsequentexceptions.

(InheritedfromException.)

GetHashCode() Servesasahashfunctionforaparticulartype.

(InheritedfromObject.)

GetObjectData(SerializationInfo,StreamingContext)

Whenoverriddeninaderivedclass,setstheSerializationInfowithinformationabouttheexception.

(InheritedfromPlException.)

GetType() Getstheruntimetypeofthecurrentinstance.

(InheritedfromException.)

HelpLink Getsorsetsalinktothehelpfileassociatedwiththisexception.

(InheritedfromException.)

HResult GetsorsetsHRESULT,acodednumericalvaluethatisassignedtoaspecificexception.

(InheritedfromException.)

InnerException GetstheExceptioninstancethatcausedthecurrentexception.

(InheritedfromException.)

MemberwiseClone() CreatesashallowcopyofthecurrentObject.

(InheritedfromObject.)

Message Getsamessagethatdescribesthecurrentexception.

(InheritedfromPlException.)

MessagePl providesomtimessomeadditionalinformationabouttheexceptionsreason.

(InheritedfromPlException.)

PlThrow() TODO

(InheritedfromPlException.)

Source Getsorsetsthenameoftheapplicationortheobjectthatcausestheerror.

(InheritedfromException.)

StackTrace Getsastringrepresentationoftheframesonthecallstackatthetimethecurrentexception

Copy

wasthrown.

(InheritedfromException.)

TargetSite Getsthemethodthatthrowsthecurrentexception.

(InheritedfromException.)

Term GetthePlTermofthisexception.

(InheritedfromPlException.)

Throw() TODO

(InheritedfromPlException.)

ToString() Theexceptionistranslatedintoamessageasproducedbyprint_message/2.Thecharacterdataisstoredinaring.

(InheritedfromPlException.)

ExamplesThissampledemonstratehowtocatchaPlTypeExceptioninC#thatisthrownsomewhereinttheprologcode.

C#

publicvoidprolog_type_exception_sample()

{

try

{

Assert.IsTrue(PlQuery.PlCall("sumlist([1,error],L)"

}

catch(PlTypeExceptionex)

{

Assert.AreEqual("is/2:Arithmetic:`error/0'isnotafunction"

}

}

InheritanceHierarchyObjectException

PlException PlTypeException

SeeAlsoPlTypeExceptionSWI-PrologManual-4.9ISOcompliantExceptionhandling

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs.Exceptions►PlTypeException►PlTypeException()

C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-

PrologPlTypeExceptionConstructor

MembersIcon Member Description

PlTypeException() InitializesanewinstanceoftheExceptionclass.

PlTypeException(String) InitializesanewinstanceoftheExceptionclasswithaspecifiederrormessage.

PlTypeException(String,Exception)

InitializesanewinstanceoftheExceptionclasswithaspecifiederrormessageandareferencetotheinnerexceptionthatisthecauseofthisexception.

PlTypeException(SerializationInfo,StreamingContext)

InitializesanewinstanceoftheExceptionclasswithserializeddata.

PlTypeException(PlTerm)Tocatchaexceptionthrownbyprolog

ForaexampleseePlException.

PlTypeException(String,PlTerm) CreatesanISOstandardPrologerrortermexpressingtheexpectedtypeandactualtermthatdoesnotsatisfythistype.

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs.Exceptions►PlTypeException►PlTypeException()

C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-

PrologPlTypeExceptionConstructor

InitializesanewinstanceoftheExceptionclass.

DeclarationSyntaxC# VisualBasic VisualC++

publicPlTypeException()

PublicSubNew

public:

PlTypeException()

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs.Exceptions►PlTypeException►PlTypeException(PlTerm)

C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-

PrologPlTypeExceptionConstructor(term)

Tocatchaexceptionthrownbyprolog

ForaexampleseePlException.

DeclarationSyntaxC# VisualBasic VisualC++

publicPlTypeException(

PlTermterm

)

PublicSubNew(_

termAsPlTerm_

)

public:

PlTypeException(

PlTermterm

)

Parametersterm(PlTerm)

APlTermcontainingthePrologexception

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs.Exceptions►PlTypeException►PlTypeException(SerializationInfo,StreamingContext)

C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-

PrologPlTypeExceptionConstructor(info,context)

InitializesanewinstanceoftheExceptionclasswithserializeddata.

DeclarationSyntaxC# VisualBasic VisualC++

protectedPlTypeException(

SerializationInfoinfo,

StreamingContextcontext

)

ProtectedSubNew(_

infoAsSerializationInfo,_

contextAsStreamingContext_

)

protected:

PlTypeException(

SerializationInfo^info,

StreamingContextcontext

)

Parametersinfo(SerializationInfo)

TheSerializationInfothatholdstheserializedobjectdataabouttheexceptionbeingthrown.

context(StreamingContext)TheStreamingContextthatcontainscontextualinformationaboutthesourceordestination.

Exceptions

Exception ConditionArgumentNullException Theinfoparameterisnull.

SerializationException TheclassnameisnullorHResultiszero(0).

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs.Exceptions►PlTypeException►PlTypeException(String)

C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-

PrologPlTypeExceptionConstructor(message)

InitializesanewinstanceoftheExceptionclasswithaspecifiederrormessage.

DeclarationSyntaxC# VisualBasic VisualC++

publicPlTypeException(

stringmessage

)

PublicSubNew(_

messageAsString_

)

public:

PlTypeException(

String^message

)

Parametersmessage(String)

Themessagethatdescribestheerror.

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs.Exceptions►PlTypeException►PlTypeException(String,PlTerm)

C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-

PrologPlTypeExceptionConstructor(expected,actual)

CreatesanISOstandardPrologerrortermexpressingtheexpectedtypeandactualtermthatdoesnotsatisfythistype.

DeclarationSyntaxC# VisualBasic VisualC++

publicPlTypeException(

stringexpected,

PlTermactual

)

PublicSubNew(_

expectedAsString,_

actualAsPlTerm_

)

public:

PlTypeException(

String^expected,

PlTermactual

)

Parametersexpected(String)

Thetypewhichwasexpected

actual(PlTerm)Theactualterm

byUweLesta,SBS-SoftwaresystemeGmbH

SendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs.Exceptions►PlTypeException►PlTypeException(String,Exception)

C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-

PrologPlTypeExceptionConstructor(message,innerException)

InitializesanewinstanceoftheExceptionclasswithaspecifiederrormessageandareferencetotheinnerexceptionthatisthecauseofthisexception.

DeclarationSyntaxC# VisualBasic VisualC++

publicPlTypeException(

stringmessage,

ExceptioninnerException

)

PublicSubNew(_

messageAsString,_

innerExceptionAsException_

)

public:

PlTypeException(

String^message,

Exception^innerException

)

Parametersmessage(String)

Theerrormessagethatexplainsthereasonfortheexception.

innerException(Exception)Theexceptionthatisthecauseofthecurrentexception,oranullreference(NothinginVisualBasic)ifnoinnerexceptionisspecified.

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

C#SwiPlCsinterface►SbsSW.SwiPlCs.Streams

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-

PrologSbsSW.SwiPlCs.StreamsNamespace

ThenamespaceSbsSW.SwiPlCs.StreamsprovidesthedelegatestoredirectthereadandwritefunctionsoftheSWI-PrologIOStreams.

WhenInitialize(String[])iscalledthe*Sinput->functions.readisreplacedbythe.NETmethod'Sread_function'and*Sinput->functions.writeby'Swrite_funktion'.

ForfurtherexamplesseethemethodsSetStreamFunctionWrite(PlStreamType,DelegateStreamWriteFunction)andSetStreamFunctionRead(PlStreamType,DelegateStreamReadFunction)

DeclarationSyntaxC# VisualBasic VisualC++

namespaceSbsSW.SwiPlCs.Streams

NamespaceSbsSW.SwiPlCs.Streams

namespaceSbsSW.SwiPlCs.Streams

TypesAllTypes Enumerations Delegates

Icon Type DescriptionDelegateStreamReadFunction See

SetStreamFunctionRead(PlStreamType,DelegateStreamReadFunction)

DelegateStreamWriteFunction See

Copy

SetStreamFunctionWrite(PlStreamType,DelegateStreamWriteFunction)

PlStreamType ThestandardSWI-Prologstreams(inputoutputerror)

RemarksNote:Thereasonforthisisdebugging.

Examples

C#

staticinternallongSwrite_function(IntPtrhandle,

{

strings=buf.Substring(0,(int)bufsize);

Console.Write(s);

System.Diagnostics.Trace.WriteLine(s);

returnbufsize;

}

staticinternallongSread_function(IntPtrhandle,System.IntPtrbuf,

{

thrownewPlLibException("SwiPlCs:Prologtrytoreadfromstdin"

}

SeeAlsoSetStreamFunctionRead(PlStreamType,DelegateStreamReadFunction)

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.de

SwiPlCsinterface►SbsSW.SwiPlCs.Streams►DelegateStreamReadFunction

C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-

PrologDelegateStreamReadFunctionDelegate

SeeSetStreamFunctionRead(PlStreamType,DelegateStreamReadFunction)

DeclarationSyntaxC# VisualBasic VisualC++

publicdelegatelongDelegateStreamReadFunction(

IntPtrhandle,

IntPtrbuffer,

longbufferSize

)

PublicDelegateFunctionDelegateStreamReadFunction(_

handleAsIntPtr,_

bufferAsIntPtr,_

bufferSizeAsLong_

)AsLong

publicdelegatelonglongDelegateStreamReadFunction

IntPtrhandle,

IntPtrbuffer,

longlongbufferSize

)

Parametershandle(IntPtr)

ACstreamhandle.simpleignoreit.

buffer(IntPtr)Apointertoastringbuffer

bufferSize(Int64)

Thesizeofthestringbuffer

ReturnValueADelegate

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs.Streams►DelegateStreamWriteFunction

C#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-

PrologDelegateStreamWriteFunctionDelegate

SeeSetStreamFunctionWrite(PlStreamType,DelegateStreamWriteFunction)

DeclarationSyntaxC# VisualBasic VisualC++

publicdelegatelongDelegateStreamWriteFunction(

IntPtrhandle,

stringbuffer,

longbufferSize

)

PublicDelegateFunctionDelegateStreamWriteFunction

handleAsIntPtr,_

bufferAsString,_

bufferSizeAsLong_

)AsLong

publicdelegatelonglongDelegateStreamWriteFunction

IntPtrhandle,

String^buffer,

longlongbufferSize

)

Parametershandle(IntPtr)

ACstreamhandle.simpleignoreit.

buffer(String)Apointertoastringbuffer

bufferSize(Int64)

Thesizeofthestringbuffer

ReturnValueADelegate

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

SwiPlCsinterface►SbsSW.SwiPlCs.Streams►PlStreamTypeC#

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-

PrologPlStreamTypeEnumeration

ThestandardSWI-Prologstreams(inputoutputerror)

DeclarationSyntaxC# VisualBasic VisualC++

publicenumPlStreamType

PublicEnumerationPlStreamType

publicenumclassPlStreamType

MembersMember DescriptionInput 0-Thestandardinputstream.

Output 1-Thestandardinputstream.

Error 1-Thestandarderrorstream.

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.deAssembly:SwiPlCs(Module:SwiPlCs)Version:1.1.60301.0(1.1.60301.0)

C#SwiPlCsinterface

Swi-cs-pl-ACSharpclasslibrarytoconnect.NETlanguageswithSWI-PrologSwiPlCsinterface

istinderquelle(classNamespaceDoc)vomnamespaceSbsSW.SwiPlCs

NamespacesNamespace DescriptionSbsSW.SwiPlCs

Theonlinedocumentationhomeishere

ThisnamespaceSbsSW.SwiPlCsprovidesan.NETinterfacetoSWI-Prolog

Overview

PrologvariablesaredynamicallytypedandallinformationispassedaroundusingtheC-interfacetypeterm_twitchisanint.InC#,term_tisembeddedinthelightweightstructPlTerm.ConstructorsandoperatordefinitionsprovideflexibleoperationsandintegrationwithimportantC#-types(string,intanddouble).

Thelistbelowsummarisestheimportantclasses/structdefinedintheC#interface.

class/struct Shortdescription

PlEngine Astaticclassrepresentstheprologengine.

PlTerm Astructrepresentingprologdata.

PlTermV AvectorofPlTerm.

PlQuery AclasstoqueryProlog.

SbsSW.SwiPlCs.CallbackThenamespaceSbsSW.SwiPlCs.Callbackprovidesthedelegatestoregister.NETmethodstobecalledfromSWI-Prolog

SbsSW.SwiPlCs.ExceptionsThesearethenamespacecommentsforSbsSW.SwiPlCs.Exceptions.

ThenamespaceSbsSW.SwiPlCs.ExceptionsprovidestheExceptionclassestocatchaprologexceptionseeSWI-PrologManual-4.9ISOcompliantExceptionhandling

PrologexceptionsaremappedtoC#exceptionsusingthesubclassPlExceptionofExceptiontorepresentthePrologexceptionterm.

Alltype-conversionfunctionsoftheinterfaceraiseProlog-compliantexceptions,providingdecenterror-handlingsupportatnoextraworkfortheprogrammer.

Forsomecommonlyusedexceptions,subclassesofPlExceptionhavebeencreatedtoexploitboththeirconstructors

foreasycreationoftheseexceptionsaswellasselectivetrappinginC#.

Currently,thesearePlTypeExceptionandPlDomainException.

SbsSW.SwiPlCs.StreamsThenamespaceSbsSW.SwiPlCs.StreamsprovidesthedelegatestoredirectthereadandwritefunctionsoftheSWI-PrologIOStreams.

WhenInitialize(String[])iscalledthe*Sinput->functions.readisreplacedbythe.NETmethod'Sread_function'and*Sinput->functions.writeby'Swrite_funktion'.

ForfurtherexamplesseethemethodsSetStreamFunctionWrite(PlStreamType,DelegateStreamWriteFunction)andSetStreamFunctionRead(PlStreamType,DelegateStreamReadFunction)

byUweLesta,SBS-SoftwaresystemeGmbHSendcommentsonthistopictoLestaatSBS-Softwaresysteme.de