Jess doesn't have an explicit else-if feature; if you put an "if" into
the "else" of another "if", then that second "if" is a separate
function call, so it needs its own parentheses. 

If I may, I will point out a few other things here: You don't need to
spell out the names of any classes in java.lang, as it's implicitly
imported, just as in Java. Second, you don't actually need to
construct Strings at all; you can call Java String methods on Jess
strings. Third, you can (and should) always omit "call" when calling a
Java instance method; it's really only needed when you're invoking a
static method. So you could clean your function up like this:

(deffunction compare-comptment-function(?s1 ?s2)
  (if (eq ?s1 ?s2) then
    (return "FFF")
    else (if (?s1 contains ?s2) then
      (printout t "COMES 1" crlf)
      (return ?s1)
      else (if (?s2 contains ?s1) then
        (printout t "COMES 2" crlf)
        (return ?s2)
        else
          (printout t "COMES 3" crlf)
          (return (str-cat ?s1 , ?s2))))))  

I think Amit Jain wrote:
[Charset iso-8859-1 unsupported, filtering to ASCII...]
> Hi all 
> I'm trying to compare two strings
> 
> (deffunction compare-comptment-function(?s1 ?s2)
> (bind ?str-buff1 (new java.lang.String ?s1))
> (bind ?str-buff2 (new java.lang.String ?s2))
> (if (eq ?s1 ?s2) then
> (return "FFF")
> else if (call ?str-buff1 contains ?str-buff2) then
> (printout t "COMES 1" crlf)
> (return ?s1)
> else if (call ?str-buff2 contains ?str-buff1) then
> (printout t "COMES 2" crlf)
> (return ?s2)
> else
> (printout t "COMES 3" crlf)
> (return (str-cat ?s1 , ?s2))))
> 
> SO when i call (compare-comptment-function "CSEE" "CS") it should return 
> "COMES 1" "CSEE"
> 
> (compare-comptment-function "CSE" "CSEEE") it should return "COMES 2" 
> "CSEEE"
> and (compare-comptment-function "AE" "CSE") it should return "COMES 3" 
> "AE,CSE" 
> 
> but it keeps going into first elseif loop in all the cases. please tell me 
> what i'm doing wrong. thanks for the help.
> -amit



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

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