I think Alexander Lamb wrote:
[Charset iso-8859-1 unsupported, filtering to ASCII...]
> I am not sure yet if this function should be in the rules or not, but here
> is something which is not accepted by the rule engine:
> 
> (defrule completerRule1
>     (Session (readyToRun TRUE) (currentCompleterQuestion ?q) (OBJECT ?x))
>     (test (> (str-index ("ASP" ?q)) -1)

What's happening on this line -- why the parentheses around
str-index's arguments? You're probably getting an error message here
like

  Message: Bad functor .
  Program text: ( str-index ( "ASP"  at line XXX

meaning that "ASP" isn't a function name, but the parentheses look
like a function call. In Jess, there are no parentheses around the
arguments to a function. Omit the extra parentheses, and this should
be fine. Note, though, that str-index returns FALSE, not -1, on no
match, so you really want just

      (test (numberp (str-index "ASP" ?q)))

or even

      (test (str-index "ASP" ?q))

(since anything but FALSE is true.)

> Now, this does not work. In the documentation, it says the parameters to
> str-index need to be ATOMS. But how? I am getting a string from my Java
> object!

The documentation is wrong; I have just updated it. Thanks for
pointing this out. 

The function (sym-cat) can be used to convert a string to an atom:
(sym-cat "ABC") is the atom ABC.

---------------------------------------------------------
Ernest Friedman-Hill  
Distributed Systems Research        Phone: (925) 294-2154
Sandia National Labs                FAX:   (925) 294-2234
Org. 8920, MS 9012                  [EMAIL PROTECTED]
PO Box 969                  http://herzberg.ca.sandia.gov
Livermore, CA 94550

--------------------------------------------------------------------
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]
--------------------------------------------------------------------

Reply via email to