If ... then (1st return) ... ;
else (2nd return) ... ;
Tests on empty / non-empty values
Tests on empty values
=== If it's empty, we can return an empty String ===
if (_str1.equals(""))
return "";
return _str1;
=== If it's empty, we can tell Mx to not evaluate the operation ===
if (_str1.equals(""))
return DoJava.DO_NOT_ADD_OPERATION_IN;
return _str1;
Tests on non-empty values
=== If it's not empty (non-equal to an empty string: "") ===
if (!_str1.equals(""))
return _str1;
return "";
Tests with numbers
==== Equality ====
if ((Str.ToDouble(_str1) == (Str.ToDouble(_str2)) return _str3;
==== Inequality ====
if ((Str.ToDouble(_str1) != (Str.ToDouble(_str2)) return _str3;
==== Strictly superior to ====
if ((Str.ToDouble(_str1) > (Str.ToDouble(_str2)) return _str3;
==== Strictly inferior to ====
if ((Str.ToDouble(_str1) < (Str.ToDouble(_str2)) return _str3;
==== Superior or equals to ====
if ((Str.ToDouble(_str1) >= (Str.ToDouble(_str2)) return _str3;
==== Inferior or equals to ====
if ((Str.ToDouble(_str1) <= (Str.ToDouble(_str2)) return _str3;
==== Strictly superior to line above or below- Warning: Case-sensitive ====
if(Str.ToDouble(_doJava.get("_str2",-1))< Str.ToDouble(_str2)) return _str2;
if(Str.ToDouble(_doJava.get("_str2",+1))< Str.ToDouble(_str2)) return _str2;
==== Strictly inferior to line above or below- Warning: Case-sensitive ====
if(Str.ToDouble(_doJava.get("_str2",-1))> Str.ToDouble(_str2)) return _str2;
if(Str.ToDouble(_doJava.get("_str2",+1))> Str.ToDouble(_str2)) return _str2;
Tests with strings
In equality tests, it is preferable to put the reference string first in order to simultaneously test whether it is null or not.
==== Perfect equality - Warning: Case-sensitive ====
if ("T0".equals(_str1)) return "1";
==== Perfect equality with line above or below- Warning: Case-sensitive ====
if (_str1.equals(_doJava.get("_str1",-1))) return "1";
if (_str1.equals(_doJava.get("_str1",+1))) return "1";
==== Inequality - Warning: Case-sensitive ====
<b>if</b> (!"T0".equals(_str1)) <b>return</b> "1";
==== Case-insensitive equality ====
if ("T0".equalsIgnoreCase(_str1)) return "1";
==== Does not contain ====
if (!_str1.equals("") && !_str1.contains("T1")) return "1";
== Operands ==
==== AND ====
if (_str1.contains("T600") && "A".equals(_str2)) return _str3;
==== OR ====
if (_str1.contains("T600") || "A".equals(_str2)) return _str3;
==Ternary Operator==
====Syntax====
(<"Condition">) ? <"Value if true"> : <"Value if false">;
====The ternary operator is a shorthand if-then statement that returns a value====
double flow = Str.ToDouble(_str1);
return (flow < 0) ? 0 : flow;
====This is equivalent to====
double flow = Str.ToDouble(_str1);
if (flow < 0)
return 0;
else
return flow;
Operands
==== AND ====
if (_str1.contains("T600") && "A".equals(_str2)) return _str3;
==== OR ====
if (_str1.contains("T600") || "A".equals(_str2)) return _str3;
Ternary Operator
====Syntax====
(<"Condition">) ? <"Value if true"> : <"Value if false">;
====The ternary operator is a shorthand if-then statement that returns a value====
double flow = Str.ToDouble(_str1);
return (flow < 0) ? 0 : flow;
====This is equivalent to====
double flow = Str.ToDouble(_str1);
if (flow < 0)
return 0;
else
return flow;