[rules-users] Using global variable in DRL file

Wolfgang Laun wolfgang.laun at gmail.com
Mon Jul 30 08:28:21 EDT 2012


Please read *carefully* - see !!!!!! below.

And make sure to check whether a DRL compilation results in an error.
Do not continue with errors.


On 30/07/2012, zeeshan <zeeshan.spring at gmail.com> wrote:
>
> Hi Laune !
>
> I am using 5.4 version. When I tried ur second solution, it gives
> *NullPointerException*.

>> This works with 5.4.0 - notice the "no-loop true". $sum has class
>> Number, this needs intValue() (or whatever) to match the parameter

!!!!!!!^^^^^^^^^^^^^^^^^^^^!!!!!!!

>> type of the setter.
>>
>> rule "accumulate Policy values into Agent"
>> no-loop true
>> when
>>     $a: Agent( $id: id )
>>     accumulate( Policy( agentId == $id, $v: value ); $sum: sum( $v ) )
>> then
>>     modify( $a ){ setValue( $sum.intValue() ) }

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!^^^^^^^^^^^^^^^^^^^^!!!!

>>     System.out.println( $a.toString() );
>> end
>>
>>
>


More information about the rules-users mailing list