"null" is meaningless in Jess. "nil" is a special symbol used to
represent the same concept as Java's "null", but in neither Jess nor
Java is null the same as a zero-length list, array, or collection.
You could use (neq (length$ ?upper) 0) to test for zero length, or
you could match like this:
(upper-match ?first $?upper)
this would match only facts where there was at least one item in the
multislot.
On Apr 9, 2007, at 5:02 AM, ricktee wrote:
[Edit]
Sorry, I have isolated the real problem to sometimes "$?upper" is a
empty
multislot.
Question: how can I do a test to ensure that if (upper-match) is
not a empty
slot, then print (upper-match)
Does $? means anything, including null? How to do a check for a empty
multislot
(defrule print-rule2
(body-muscle (upper-match $?upper) (lower-match $?lower))
(test (neq $?upper null ))
(test (neq $?lower null))
=>
(printout t "upper is not empty" $?upper)
(printout t "lower is not empty" $?lower))
Please ignore the post below
sorry,
Rick
[Edit]
*************************************************************
Hi,
This might sound weird but how do I convert a Jess multislot list
into a
Jess string, inside Jess?
Its hard for me to explain but I need it to make the following
method work.
"upper" needs to be replaced by $?upper
"lower" needs to be replaced by $?lower
But if I replace it as it is, the output is wrong. So I need to
convert
$?upper into a string 1st, then replace the "lower" with the string.
Question: How do I convert $?upper into a string? And bind it to
some ?name.
thanks n rgds
Rick
(defrule print-rule
(user (session $?session))
(program-cardio (c-dura ?cc) (i-dura ?ci) (m-dura ?cm))
(program-muscle (c-dura ?mc) (i-dura ?mi) (m-dura ?mm))
(body-muscle (upper-match $?upper) (lower-match $?lower))
=>
(bind ?totalwksC (+ ?cc ?ci ?cm))
(bind ?totalwksM (+ ?mc ?mi ?mm))
(bind ?countwks 1)
(bind ?next 1)
(bind ?muscle "")
(bind ?upper $?upper)
(bind ?lower $?lower)
(while (<= ?countwks ?totalwksC) do
(foreach ?date $?session
(if (<= ?countwks ?totalwksM) then
(if (= ?next 1) then
(bind ?muscle "upper")
(bind ?next 0)
else
(bind ?muscle "lower")
(bind ?next 1)
);if
else
(bind ?muscle "")
);if
(assert (each-week (ident each-week) (week ?countwks) (day ?date)
(cardio
cardio) (muscle ?muscle)))
);for
(bind ?countwks (+ ?countwks 1))
);while
);close rule
--
View this message in context: http://www.nabble.com/Jess%3A-
checking-if-a-multislot-is-empty-tf3546357.html#a9899823
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 owner-jess-
[EMAIL PROTECTED]
--------------------------------------------------------------------
---------------------------------------------------------
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://www.jessrules.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]
--------------------------------------------------------------------