Reference Manual

 

Volume II

Advanced Programming Guide

 

 

Quicksilver Beta

February 7th 2008

 

 

 

 

 

 


CLIPS Advanced Programming Guide

Quicksilver Beta  February 7th 2008

 

CONTENTS

License Information....................................................................................................................... i

Preface............................................................................................................................................ iii

Acknowledgements...................................................................................................................... vii

Section 1 ‑ Introduction................................................................................................................ 1

1.1 Warning About Interfacing With CLIPS.............................................................................. 1

1.2 C++ Compatibility............................................................................................................... 2

1.3 Threads and Concurrency.................................................................................................... 2

1.4 Garbage Collection............................................................................................................... 3

Section 2 ‑ Installing and Tailoring CLIPS................................................................................. 9

2.1 Installing CLIPS.................................................................................................................. 9

2.1.1 Additional Considerations......................................................................................... 12

2.2 Tailoring CLIPS................................................................................................................. 13

Section 3 ‑ Integrating CLIPS with External Functions.......................................................... 19

3.1 Declaring User‑Defined External Functions...................................................................... 19

3.2 Passing Arguments from CLIPS to External Functions..................................................... 23

3.2.1 Determining the Number of Passed Arguments........................................................ 23

3.2.2 Passing Symbols, Strings, Instance Names, Floats, and Integers............................. 23

3.2.3 Passing Unknown Data Types.................................................................................. 25

3.2.4 Passing Multifield Values......................................................................................... 28

3.3 Returning Values To CLIPS From External Functions...................................................... 30

3.3.1 Returning Symbols, Strings, and Instance Names.................................................... 31

3.3.2 Returning Boolean Values........................................................................................ 32

3.3.3 Returning External Addresses and Instance Addresses............................................ 34

3.3.4 Returning Unknown Data Types.............................................................................. 34

3.3.5 Returning Multifield Values...................................................................................... 37

3.4 User‑Defined Function Example........................................................................................ 40

Section 4 ‑ Embedding CLIPS................................................................................................... 43

4.1 Environment Functions...................................................................................................... 43

4.1.1 AddClearFunction..................................................................................................... 43

4.1.2 AddPeriodicFunction................................................................................................ 44

4.1.3 AddResetFunction.................................................................................................... 44

4.1.4 BatchStar................................................................................................................... 45

4.1.5 Bload......................................................................................................................... 45

4.1.6 Bsave........................................................................................................................ 46

4.1.7 Build......................................................................................................................... 46

4.1.8 Clear.......................................................................................................................... 46

4.1.9 Eval........................................................................................................................... 47

4.1.10 FunctionCall............................................................................................................ 47

4.1.11 GetAutoFloatDividend............................................................................................ 48

4.1.12 GetDynamicConstraintChecking............................................................................. 48

4.1.13 GetSequenceOperatorRecognition.......................................................................... 48

4.1.14 GetStaticConstraintChecking.................................................................................. 49

4.1.15 InitializeEnvironment.............................................................................................. 49

4.1.16 Load........................................................................................................................ 49

4.1.17 RemoveClearFunction............................................................................................. 50

4.1.18 RemovePeriodicFunction........................................................................................ 50

4.1.19 RemoveResetFunction............................................................................................ 50

4.1.20 Reset....................................................................................................................... 51

4.1.21 Save........................................................................................................................ 51

4.1.22 SetAutoFloatDividend............................................................................................ 51

4.1.23 SetDynamicConstraintChecking............................................................................. 52

4.1.24 SetSequenceOperator Recognition.......................................................................... 52

4.1.25 SetStaticConstraintChecking................................................................................... 53

4.2 Debugging Functions......................................................................................................... 53

4.2.1 DribbleActive............................................................................................................ 53

4.2.2 DribbleOff................................................................................................................ 53

4.2.3 DribbleOn................................................................................................................. 54

4.2.4 GetWatchItem........................................................................................................... 54

4.2.5 Unwatch.................................................................................................................... 54

4.2.6 Watch........................................................................................................................ 55

4.3 Deftemplate Functions....................................................................................................... 55

4.3.1 DeftemplateModule................................................................................................... 55

4.3.2 DeftemplateSlotAllowedValues................................................................................ 55

4.3.3 DeftemplateSlotCardinality....................................................................................... 56

4.3.4 DeftemplateSlotDefaultP........................................................................................... 56

4.3.5 DeftemplateSlotDefaultValue.................................................................................... 57

4.3.6 DeftemplateSlotExistP.............................................................................................. 57

4.3.7 DeftemplateSlotMultiP.............................................................................................. 57

4.3.8 DeftemplateSlotNames.............................................................................................. 58

4.3.9 DeftemplateSlotRange............................................................................................... 58

4.3.10 DeftemplateSlotSingleP.......................................................................................... 58

4.3.11 DeftemplateSlotTypes............................................................................................. 59

4.3.12 FindDeftemplate...................................................................................................... 59

4.3.13 GetDeftemplateList................................................................................................. 60

4.3.14 GetDeftemplateName.............................................................................................. 60

4.3.15 GetDeftemplatePPForm.......................................................................................... 60

4.3.16 GetDeftemplateWatch............................................................................................. 61

4.3.17 GetNextDeftemplate................................................................................................ 61

4.3.18 IsDeftemplateDeletable........................................................................................... 61

4.3.19 ListDeftemplates..................................................................................................... 61

4.3.20 SetDeftemplateWatch.............................................................................................. 62

4.3.21 Undeftemplate......................................................................................................... 62

4.4 Fact Functions.................................................................................................................... 63

4.4.1 Assert........................................................................................................................ 63

4.4.2 AssertString.............................................................................................................. 63

4.4.3 AssignFactSlotDefaults............................................................................................ 64

4.4.4 CreateFact................................................................................................................. 65

4.4.5 DecrementFactCount................................................................................................. 67

4.4.6 FactDeftemplate........................................................................................................ 68

4.4.7 FactExistp................................................................................................................. 68

4.4.8 FactIndex.................................................................................................................. 68

4.4.9 Facts.......................................................................................................................... 68

4.4.10 FactSlotNames........................................................................................................ 69

4.4.11 GetFactDuplication................................................................................................. 69

4.4.12 GetFactList.............................................................................................................. 70

4.4.13 GetFactListChanged................................................................................................ 70

4.4.14 GetFactPPForm...................................................................................................... 71

4.4.15 GetFactSlot............................................................................................................. 71

4.4.16 GetNextFact............................................................................................................ 71

4.4.17 GetNextFactInTemplate.......................................................................................... 72

4.4.18 IncrementFactCount................................................................................................ 73

4.4.19 LoadFacts................................................................................................................ 73

4.4.20 LoadFactsFromString............................................................................................. 74

4.4.21 PPFact..................................................................................................................... 74

4.4.22 PutFactSlot.............................................................................................................. 74

4.4.23 Retract..................................................................................................................... 75

4.4.24 SaveFacts................................................................................................................ 75

4.4.25 SetFactDuplication.................................................................................................. 76

4.4.26 SetFactListChanged................................................................................................ 76

4.5 Deffacts Functions............................................................................................................. 77

4.5.1 DeffactsModule........................................................................................................ 77

4.5.2 FindDeffacts............................................................................................................. 77

4.5.3 GetDeffactsList......................................................................................................... 77

4.5.4 GetDeffactsName...................................................................................................... 78

4.5.5 GetDeffactsPPForm.................................................................................................. 78

4.5.6 GetNextDeffacts....................................................................................................... 78

4.5.7 IsDeffactsDeletable................................................................................................... 79

4.5.8 ListDeffacts............................................................................................................... 79

4.5.9 Undeffacts................................................................................................................. 79

4.6 Defrule Functions.............................................................................................................. 80

4.6.1 DefruleHasBreakpoint.............................................................................................. 80

4.6.2 DefruleModule.......................................................................................................... 80

4.6.3 FindDefrule............................................................................................................... 80

4.6.4 GetDefruleList.......................................................................................................... 80

4.6.5 GetDefruleName....................................................................................................... 81

4.6.6 GetDefrulePPForm................................................................................................... 81

4.6.7 GetDefruleWatchActivations.................................................................................... 81

4.6.8 GetDefruleWatchFirings........................................................................................... 82

4.6.9 GetIncrementalReset................................................................................................. 82

4.6.10 GetNextDefrule....................................................................................................... 82

4.6.11 IsDefruleDeletable.................................................................................................. 83

4.6.12 ListDefrules............................................................................................................ 83

4.6.13 Matches................................................................................................................... 83

4.6.14 Refresh.................................................................................................................... 84

4.6.15 RemoveBreak.......................................................................................................... 84

4.6.16 SetBreak.................................................................................................................. 84

4.6.17 SetDefruleWatchActivations................................................................................... 84

4.6.18 SetDefruleWatchFirings.......................................................................................... 85

4.6.19 SetIncrementalReset................................................................................................ 85

4.6.20 ShowBreaks............................................................................................................ 85