Page 1 of 1

MField Does Not Compare in Display Logic

PostPosted: Thu Aug 05, 2004 6:19 pm
by red1
This is discovered when in WindowTabField, in the Field Tab, at the Display Logic control, you can only do "equals to" and "not equals to", missing on the "greater than" and "less than" stmts.

I contributed this in version 250 but now in 251e it still isnt there. So here it is again. Go to MField.java in your Eclipse, and put in these two snippets.
You can also pick up the whole code here http://compiere.red1.org/MField.zip. Its is version 251e, fully commented with usage example. :P

private boolean evaluateLogicTuple (String logic)
{
//red1 -- init Float variables to handle string Evals in < > comparisons
float f1 = 0; //red1
float f2 = 0; //red1
StringTokenizer st = new StringTokenizer(logic.trim(), "<>!=^", true); //red1 <> added here

=====================2nd snippet a bit lower ===========

// Logical Comparison
boolean result = firstEval.equals(secondEval);
if (!compare.equals("="))
result = !result;
//
// red1 -
if (compare.equals(">"))
{ result = false;
f1 = Float.parseFloat(firstEval);
f2 = Float.parseFloat(secondEval);
if (f1>f2)result = true;
}
//red1 --
//red1 - if compare '<'
if (compare.equals("<"))
{ result = false;
f1 = Float.parseFloat(firstEval);
f2 = Float.parseFloat(secondEval);
if (f1<f2)result = true;
}
//Set in WindowTabColumn, Field Tab, DisplayLogic example:"@thisField@>99 | @thisField@=99"
//red1 -- thisField is firstEval, 99 is secondEval -- end
if (Log.isTraceLevel(10))
Log.trace(10, "MField.evaluateLogicTuple - " + logic + "=> \"" + firstEval + "\" " + compare + " \"" + secondEval + "\" => " + result);
//
return result;
} // evaluateLogicTouple

Finally Fixed by Jorg... interesting to see how they do it

PostPosted: Wed Aug 18, 2004 10:01 am
by red1
Here's a message reply from Compiere, that this bug is fixed. So what u ppl can do is to reload the latest MField.java from sourceforge and see how it is properly done. Should be fun to compare between a true pro and me as a dummy :oops: All in good jest!

Category: Application Dictionary
Group: R2.5.1+
>Status: Closed
>Resolution: Fixed
Priority: 5
Submitted By: d. oon poh shin (red1)
>Assigned to: Jorg Janke (jjanke)
Summary: WindowTabField doesnt handle >, < display logic - fixed!

Initial Comment:
I fixed a bug in MField.java so that it can handle display
logic comparisons 'greater than' and 'less than'.

When u go into WindowTabColumn, Field tab, Display
Logic column, u can only specify '!', '=' when the Help
notes said u could also do >,<.

Now it can. Using Floats to evaluate.
Done on version251e.

Fully commented //red1.

best regards
red1

----------------------------------------------------------------------

>Comment By: Jorg Janke (jjanke)
Date: 2004-08-17 01:06

Message:
Logged In: YES
user_id=87038

** Fixed in next release (R2.5.1e) **

----------------------------------------------------------------------

Comment By: Jorg Janke (jjanke)
Date: 2004-08-17 01:06

Message:
Logged In: YES
user_id=87038

Sorry, it needs to handle
AA>BB .. strings
1>2 .. numbers
1>AA .. strings
0>0.0
@variable@>@variable@
--
fixed.