Please, help me with my project (CLIPS 6.3 and NetBeans IDE)

50 views
Skip to first unread message

Irina Ira

unread,
Jan 25, 2020, 1:08:23 PM1/25/20
to CLIPSESG
Hello,

I make an university project using CLIPS and Java.
I am trying to get some fact from a clips file. 
I used code below:

clips.run();


String evaluar = "find-all-facts ((?v mydiagnosis)) TRUE";

PrimitiveValue value = clips.eval(evaluar);


String diagn= value.get(0).getFactSlot("diagn").toString();


JOptionPane.showMessageDialog(rootPane, "Diagnosis "+diagn);

clips.reset();


But it doesn't work. I have an error:
error: cannot find symbol
symbol: method get(int)
location: variable value of type PrimitiveValue

I tried to use the other code:

clips.run();


String evaluar = "find-all-facts ((?v mydiagnosis)) TRUE";

PrimitiveValue value = clips.eval(evaluar);


String diagn=((FactAddressValue) value.getValue()).getFactSlot("diagn").toString(); // There is no possible to set value.get(0) --- Why???


JOptionPane.showMessageDialog(rootPane, "Diagnosis "+diagn);

clips.reset();


But it doesn't work too.


Can someone help me please?


Thanks.



CLIPS Support

unread,
Jan 27, 2020, 1:55:18 PM1/27/20
to CLIPSESG
Calling the find-all-facts function using Eval is going to return a multifield value, so you need to cast the return value to a MultifieldValue in order to use the get method. You can see an example of this in the CLIPSJNI demo program files AutoDemo.java and AnimalDemo.java:

String evalStr = "(find-fact ((?f UI-state)) TRUE)";

FactAddressValue fv = (FactAddressValue) ((MultifieldValue) clips.eval(evalStr)).get(0);

if (fv.getFactSlot("state").toString().equals("conclusion")) ...
Reply all
Reply to author
Forward
0 new messages