I am not getting do execute a rule when I am into a function.
The code of my program is this:
;;******** DECLARAGUES **************
(import java.awt.*)
(import jess.awt.*)
;;***********************************
;;******** DEFTEMPLATES ***********
;;***********************************
;;******** DEFGLOBALS ***************
(defglobal ?*frame* = 0)
(defglobal ?*tipo* = 0)
(defglobal ?*menutipo* = 0)
(defglobal ?*menusubtipo* = 0)
(defglobal ?*menuconsciente* = 0)
(defglobal ?*botao* = 0)
(defglobal ?*panel1* = 0)
(defglobal ?*panel2* = 0)
(defglobal ?*vartipo* = 0)
(defglobal ?*varsub* = 0)
(defglobal ?*varconsc* = 0)
;;***********************************
;;******** FATOS ********************
(deffacts tipos-queimadura
(queimadura Fogo 1)
(queimadura Fogo 2)
(queimadura Fogo 3 Sim)
(queimadura Fogo 3 Nao)
; (queimadura (tipo Fumaca) (consciente Sim))
; (queimadura (tipo Fumaca) (consciente Nao))
; (queiamdura (tipo Substancia) (subtipo Pele))
; (queimadura (tipo Substancia) (subtipo Olhos))
; (queimadura (tipo Substancia) (subtipo Boca))
; (queimadura (tipo Eletricidade) (consciente Sim))
; (queimadura (tipo Eletricidade) (consciente Nao))
)
;;***********************************
;;******** DEFFUNCTIONS *************
(deffunction cria-frame ()
(bind ?*frame* (new Frame "Trab - JESS"))
(set ?*frame* background (new Color 255 200 0))
(set ?*frame* layout (new GridLayout 1 2))
;; * VER TAMANHO *
; (set ?*frame* resize 300 300)
)
;;******** COMPONENTES **************
(deffunction adiciona-componentes ()
(bind ?*panel1* (new Panel (new GridLayout 4 1)))
(?*panel1* add (new Label "Tipo"))
(bind ?*menutipo* (new Choice))
(?*menutipo* addItem "");
(?*menutipo* addItem "Fogo")
(?*menutipo* addItem "Substancia")
(?*menutipo* addItem "Fumaca")
(?*menutipo* addItem "Eletricidade")
(?*panel1* add ?*menutipo*)
(?*panel1* add (new Label "Subtipo"))
(bind ?*menusubtipo* (new Choice))
(?*menusubtipo* addItem "");
(?*menusubtipo* addItem "1")
(?*menusubtipo* addItem "2")
(?*menusubtipo* addItem "3")
(?*menusubtipo* addItem "Pele")
(?*menusubtipo* addItem "Olhos")
(?*menusubtipo* addItem "Boca")
(?*panel1* add ?*menusubtipo*)
(?*panel1* add (new Label "Vitima"))
(bind ?*menuconsciente* (new Choice))
(?*menuconsciente* addItem "");
(?*menuconsciente* addItem "Sim")
(?*menuconsciente* addItem "Nao")
(?*panel1* add ?*menuconsciente*)
(bind ?*botao* (new Button "Processa"))
(?*panel1* add ?*botao*)
(?*frame* add ?*panel1*)
(bind ?*panel2* (new Panel (new BorderLayout )))
;;* ver *
(bind ?*texto* (new TextArea "Bem-vindo Teste Teste"))
;;*******
(?*panel2* add ?*texto*)
(?*frame* add ?*panel2*)
)
;;******** ANCORAS ******************
(deffunction add-behaviours ()
(?*frame* addWindowListener
(new WindowListener manipula-frame (engine))
)
(?*menutipo* addItemListener
(new ItemListener manipula-menutipo (engine))
)
(?*menusubtipo* addItemListener
(new ItemListener manipula-menusubtipo (engine))
)
(?*menuconsciente* addItemListener
(new ItemListener manipula-menuconsciente (engine))
)
(?*botao* addActionListener
(new ActionListener manipula-botao (engine))
)
)
;;************************************
;;******* CRIA FRAME *****************
(deffunction mostra-frame ()
(?*frame* validate)
(?*frame* pack)
(?*frame* show)
)
;;***********************************
;;******** EVENTOS ******************
(deffunction manipula-frame (?event)
(if (= (?event getID) (get-member ?event WINDOW_CLOSING)) then
(call (get ?event source) dispose)
(call System exit 0)
)
)
(deffunction manipula-menutipo (?event)
; (printout t (call (get ?event item) toString))
(assert (tipo Fogo))
; (printout t "Verifica [TIPO]: " ?*vartipo* crlf)
)
(deffunction manipula-menusubtipo (?event)
; (printout t "Escolha [SUBTIPO]: "(call (get ?event item) toString) crlf)
(bind ?*varsub* (call (get ?event item) toString))
; (printout t "Verifica [SUBTIPO]: " ?*varsub* crlf)
)
(deffunction manipula-menuconsciente (?event)
; (printout t "Escolha [CONSCIENTE]: "(call (get ?event item) toString)
crlf)
(bind ?*varconsc* (call (get ?event item) toString))
; (printout t "Verifica [CONSCIENTE]: " ?*varconsc* crlf)
)
(deffunction manipula-botao (?event)
(printout t "Funcionou !!!!!!" crlf ?*vartipo* " " ?*varsub* " "
?*varconsc* crlf)
)
;;*******************************************************************
;;******** REGRAS *******************
(defrule inicio
?init <- (initial-fact)
=>
(retract ?init)
(cria-frame)
(adiciona-componentes)
(add-behaviours)
(mostra-frame)
)
(defrule fogo
?tipo <- (tipo Fogo)
=>
(retract ?fato)
(printout t "...teste..." crlf)
)
when I am into the function "manipula-menutipo", the program should enter in
the defrule "fogo", but when I select the option, I don't get the expected
result.
What can I do to solver this problem?
Thanks
Leandro
Obs.: I think I was clear now.
_________________________________________________________
Voce quer um iGMail protegido contra vmrus e spams?
Clique aqui: http://www.igmailseguro.ig.com.br
Ofertas imperdmveis! Link: http://www.americanas.com.br/ig/
--------------------------------------------------------------------
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]
--------------------------------------------------------------------