On Feb 22, 2007, at 6:47 PM, [EMAIL PROTECTED] wrote:
Hi, I have a query on how once you have added some values to an array
list, how in Jess you can then retrieve the contents of the array
as one
String?
(defglobal ?*rule7List* = (new java.util.ArrayList))
Well, ArrayList.toString() returns something like ["A", "B", "C"] .
If that's good enough, then you just want
(bind ?s (?*rule7list* toString))
If you want to do something more complex yourself, you probably want
a loop like
(bind ?s "")
((foreach ?e ?*rule7list*
(bind ?s (str-cat ?s " " ?e))) trim)
which is a translation of Java code something like
String s = "";
for (String e: rule7List) {
s = s + " " + e;
}
s = s.trim();
(defrule rule7-reminder
(farming-generalrules (name "rule7")(status "on"))
(test (and (eq ?*month* ?*cattle-in-month*)(eq ?*day* ?*cattle-
in-day*)))
=>
(?*rule7List* add "(Cattle In)")
(printout t "Rule7" crlf))
(defrule rule7-reminder
(farming-generalrules (name "rule7")(status "on"))
(test (and (eq ?*month* ?*cattle-out-month*)(eq ?*day*
?*cattle-out-day*)))
=>
(?*rule7List* add "(Cattle Out)")
(printout t "Rule7" crlf))
So for this example I'd want a String that read (Cattle In)(Cattle
Out) if
these two reminders were both scheduled for today's date 22/2.
--------------------------------------------------------------------
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]
--------------------------------------------------------------------