I think Srini wrote: > > (defrule CreateAccountRule "AccountCreationRule" > > => > (printout t "id=" ?fact crlf) > (printout t "name=" ?name crlf) > (printout t "Properties=" $?properties crlf) > (printout t "PropertyGroups=" $?propertyGroups crlf) > > > ) > > (clear) > (batch jessrules.clp) > (watch all) > (facts) > (run) > If run a batch file, below i get the output... > Jess> (batch cmd.clp) > f-0 (MAIN::Property (path \Account) (name firstName) (datatype STRING)) > f-1 (MAIN::Property (path \Account) (name lastName) (datatype STRING)) > f-2 (MAIN::Property (path \Account\AccountAddress) (name city) (datatype > STRIN > G)) > f-3 (MAIN::Property (path \Account\AccountAddress) (name state) (datatype > STRI > NG)) > f-4 (MAIN::PropertyGroup (path \Account) (name AccountAddress) (Properties > <Fa > ct-2> <Fact-3>)) > f-5 (MAIN::BusinessObject (name Account) (parentPaths ) (Properties > <Fact-0> < > Fact-1>) (PropertyGroups <Fact-4>)) > For a total of 6 facts. > FIRE 1 MAIN::CreateAccountRule f-5 > id=<Fact-5> > name=Account > Properties=(<Fact-0> <Fact-1>) > PropertyGroups=(<Fact-4>) > 1 > > Now my question is how read the slots and multislots of $?properties > (name, dataType etc) and $?propertyGroups (name, dataType, > Properties). The property groups itself another multislot Properties, > so again I need to retrive the slots of these properties. > Thanks in adavance!! > Srini >
The Properties slot contains a list of facts. You can match a whole fact using a "pattern binding", like the variable "?fact" in your example rules. The following rule will fire once for each Property fact that appears in the Properties slot of any BusinessObject fact: (defrule process-one-property (BusinessObject (Properties $? ?property $?)) ?property <- (Property (name ?name) (dataType ?type) (properties $?properties)) => ;; Do something with ?name, ?type, ?properties ) "$?" is a blank multifield -- a multifield that matches zero or more items in a list, but has no name and so is simply discarded. The pattern "$? ?property $?" matches zero or more values, followed by a single value which will be bound to ?property, followed by zero or more additional values. --------------------------------------------------------- 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] --------------------------------------------------------------------
