[rules-users] For loop inside a modify block problem

Swindells, Thomas TSwindells at nds.com
Wed Jan 11 11:06:45 EST 2012



From: rules-users-bounces at lists.jboss.org [mailto:rules-users-bounces at lists.jboss.org] On Behalf Of Mark Proctor
Sent: 11 January 2012 15:27
To: rules-users at lists.jboss.org
Subject: Re: [rules-users] For loop inside a modify block problem

Why no braces after SomeBusinessLogic?

Also your logic is wrong there. Item is not a collection so your for loop is repeating the same action over and over again for the same data.
[Swindells, Thomas] It does look like that but it depends what the action is. Perhaps it is integrating with a rubbish stock system which can only remove one item at a time, to remove n identical items you have to call it n times.


Mark

On 11/01/2012 09:27, Martin A wrote:
Hi, Davide,

Here is how my rule looks like :

when
    $item : Item(param1 != 0, param2 == 0, !(this instanceof SpecialItem))
    $gsc : SomeBusinessLogic
then
    $gsc.doSomething($item.id<http://item.id/>);
    for (int i = 0; i < $item.quantity; i++) {
        $gsc.doSomethingElse($item.id<http://item.id/>);
    }
    update($gsc);
end

The above snippet throws an error @ i < $item.quantity, and says 'no such identifier $item'...
I can't figure out what might be causing this.

Thanks

On Tue, Jan 10, 2012 at 10:08 PM, Davide Sottara <dsotty at gmail.com<mailto:dsotty at gmail.com>> wrote:
Did you remember to bind $item to some expression in the LHS ? Maybe you just
called that "item" without the $ :)
Davide

(the original "modify" syntax is still wrong anyway)

--
View this message in context: http://drools.46999.n3.nabble.com/rules-users-For-loop-inside-a-modify-block-problem-tp3648460p3648718.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
_______________________________________________
rules-users mailing list
rules-users at lists.jboss.org<mailto:rules-users at lists.jboss.org>
https://lists.jboss.org/mailman/listinfo/rules-users





_______________________________________________

rules-users mailing list

rules-users at lists.jboss.org<mailto:rules-users at lists.jboss.org>

https://lists.jboss.org/mailman/listinfo/rules-users


________________________________

**************************************************************************************
This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmaster at nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary.

NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00
**************************************************************************************
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20120111/c0148b61/attachment.html 


More information about the rules-users mailing list