2017-01-20 17 views
0

我不想匹配jess-object的值(字符串),而比较值是字符串和另一个字段的组合。Jess-Rule:Str-Cat字段比较不会编译

这里一个简单的( “可运行”)例如:

(defclass Person (is-a :THING) (slot name (type string)) (slot email (type string))) 
(mapclass Person) 

(make-instance Andy of Person (name "Andy") (email "[email protected]")) 

(defrule search 
(object (OBJECT ?tmpPerson) 
    (is-a Person) 
    (email (str-cat (slot-get ?tmpPerson name) "@mail")) 
) 
=> 
(print t "found") 
) 

但代码不JessTab编译。看来,该字段名 “” 后的 “” 是不允许的

错误:

Jess reported an error in routine Jesp.parsePattern. 
    Message: Bad slot value at token '('. 
    Program text: (defrule search (object (OBJECT ?tmpPerson) (is-a Person) (name ( at line 5. 

我怎样才能解决这个

谢谢?推进

回答

1

以匹配函数的返回值的模式,你必须先于函数调用等号 - 即“(名称=(STR-猫......”

+0

非常感谢。这使得我的一天:-) – user2667549

+0

改为[...](email =(str-cat(slot-get?tmpPerson name)“@mail”))(我的错误,我想输入“email”-Slot而不是“名称”) – user2667549