Good day,
Im using java to load the "cardio.clp" file then java ex-commend a string to
create ththe following fact in jess.
(program-cardio
(ident cardio-low)
(cond-inte 40) (cond-dura 6)
(impr-inte 70) (impr-dura 20)
(main-inte 70) (main-dura 1)))
I read in the "Jess in action" book (p311) there is a "findFactByFact()"
method, but I dont know how to use it. Can you please help me? How do I get
the (program-cardio) fact out of Jess? Is ValueVector the correct format to
store the fact? Or should I use vectors?
And is there a way to auto format the retrieved fact in a array for easy
using? Or something similar? Like-
String [] [] cardio_program = {
("ident", "cardio-low"),
("cond-inte", "40"), ("cond-dura", "6"),
("impr-inte", "70"), ("impr-dura", "20"),
("main-inte", "70"), ("main-dura", "1") }
The "cond-inte 40" stands for "conditioning intensity at 40%" which Im
suppose to use it for some java caculation.
Thank you very much for your help
rick
Below is the scale down program
http://www.geocities.com/t_web_design/TestFrame.java
http://www.geocities.com/t_web_design/cardio.txt
****************************************************************************
//TestFrame.java
import jess.*;
import java.util.*;
public class TestFrame{
private static Rete engine;
public static void main(String[] args)
{
String assert_fact = "(assert (program-cardio (ident
cardio-low)(cond-inte
40) (cond-dura 6)(impr-inte 70) (impr-dura 20)(main-inte 70) (main-dura
1)) )";
try
{
engine = new Rete();
engine.reset();
engine.batch("cardio.clp");
engine.reset();
engine.executeCommand(assert_fact);
engine.run();
ValueVector get_fact = engine.findFactByFact("program-cardio");
Vector temp =
get_fact.factValue(engine.getGlobalContext());
}
catch (JessException ex)
{ System.err.println("ERROR"); }
} //close main
}
*******************************************************************************
;; cardio.clp
;;;; template for a cardio exercise program ;;;;
(deftemplate program-cardio
(slot ident)
(slot cond-inte)
(slot cond-dura)
(slot impr-inte)
(slot impr-dura)
(slot main-inte)
(slot main-dura)
(slot explanation) );;close
;;;; rule , to say the fact has been created by Java ;;;;;;;;
(defrule access-by-java
(program-cardio (ident cardio-low))
=>
(printout t "The jess file has been accessed by Java, (program-cardio) fact
created" crlf ) );;close
--
View this message in context:
http://www.nabble.com/Retrieve-Fact-from-Java-tf3432213.html#a9567941
Sent from the Jess mailing list archive at Nabble.com.
--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify [EMAIL PROTECTED]
--------------------------------------------------------------------