Finding negative numbers in a field in ILog

I have a following requirement in Ilog Jrules,

Having an Integer field that contains both positive and negative numbers. Requirement is to loop through the Integer field, find and remove the negative sign in the negative numbers. It sounds simple but I could n't find a way to to this.

Any help or pointers would be highly appreciated. Many thanks.

Answers


(Supposing that XArray is an input/output Array of Integer in your rule project) You can create a rule like this:

definitions 
set 'x' to a Number from  XArray;
if
x is less than 0
then
set x to -x;

PS: don't forget to add the rule in a ruleTask (with RetePlus Alogorithm: default) in the main ruleflow.


I ve created the following function in BOM to XML mapping and passing all the incoming integer field values through this, which solved the problem.

if (integer < 0) return integer * -1; else return integer;


Need Your Help

Using Groovy's JsonSlurper for actual POGO mapping?

json groovy

I've seen countless examples of JsonSlurper used to parse JSON text and create a "JSON object" out of it:

Unable to redirect it with PHP_SELF in action

php session redirect

I am trying to redirect my page if the logins are true and also new with sessions too so it should work like if the details are not entered it should show an error message. Please help me with this...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.