Changeset 3656
- Timestamp:
- Aug 13, 2007, 8:03:01 AM (16 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/core/net/sf/basedb/util/jep/convert/ConverterFactory.java
r3604 r3656 39 39 import org.nfunk.jep.function.Divide; 40 40 import org.nfunk.jep.function.Exp; 41 import org.nfunk.jep.function.If; 41 42 import org.nfunk.jep.function.Logarithm; 42 43 import org.nfunk.jep.function.Multiply; … … 95 96 converters.put(Abs.class, new AbsConverter()); 96 97 converters.put(Exp.class, new ExpConverter()); 98 converters.put(If.class, new IfConverter()); 97 99 98 100 // Constant values -
trunk/src/test/TestJep.java
r3604 r3656 46 46 String expression1 = "raw(ch1FgMean) - raw(ch1BgMean)"; 47 47 String expression2 = "ln((raw(ch1FgMean) - raw(ch1BgMean)) / (raw(ch2FgMean) - raw(ch2BgMean)))"; 48 String bigExpression = "1+sqrt(2)-exp(3)*abs(-4)/log(5)+ln(5.99)+x ";48 String bigExpression = "1+sqrt(2)-exp(3)*abs(-4)/log(5)+ln(5.99)+x+if(a<b, 11, -11)"; 49 49 String restriction1 = expression1 + " > 0"; 50 50 String restriction2 = expression2 + " > 2"; -
trunk/www/common/expression_builder.jsp
r3456 r3656 193 193 if (frm.expression.value != '') 194 194 { 195 var expression = frm.expression.value.replace('if(', 'jepIf('); 195 196 try 196 197 { 197 var result = eval( frm.expression.value);198 var result = eval(expression); 198 199 alert('The expressions seems to be ok.\nNote! This feature is experimental and may not be 100% correct.'); 199 200 } … … 286 287 return Math.random() * 100; 287 288 } 289 function jepIf(condition, ifTrue, ifFalse) 290 { 291 if (condition == undefined || ifTrue == undefined || ifFalse == undefined) 292 { 293 throw 'if() needs 3 arguments'; 294 } 295 return condition ? ifTrue : ifFalse; 296 } 288 297 </script> 289 298 </base:head> … … 303 312 tooltip="BOOLEAN AND: expr1 && expr2" 304 313 onclick="encloseSelection(' && ', '')" 305 visible="<%=restrictions%>"306 314 /> 307 315 <tbl:button … … 309 317 tooltip="BOOLEAN OR: expr1 || expr2" 310 318 onclick="encloseSelection(' || ', '')" 311 visible="<%=restrictions%>"312 319 /> 313 320 <tbl:button … … 315 322 tooltip="BOOLEAN NOT: !expr1" 316 323 onclick="encloseSelection('!', '')" 317 visible="<%=restrictions%>"318 324 /> 319 325 <tbl:button … … 321 327 tooltip="EQUAL: expr1 == expr2" 322 328 onclick="encloseSelection(' == ', '')" 323 visible="<%=restrictions%>"324 329 /> 325 330 <tbl:button … … 327 332 tooltip="INEQUAL: expr1 != expr2" 328 333 onclick="encloseSelection(' != ', '')" 329 visible="<%=restrictions%>"330 334 /> 331 335 <tbl:button … … 333 337 tooltip="LESS: expr1 < expr2" 334 338 onclick="encloseSelection(' < ', '')" 335 visible="<%=restrictions%>"336 339 /> 337 340 <tbl:button … … 339 342 tooltip="LESS OR EQUAL: expr1 <= expr2" 340 343 onclick="encloseSelection(' <= ', '')" 341 visible="<%=restrictions%>"342 344 /> 343 345 <tbl:button … … 351 353 tooltip="MORE: expr1 > expr2" 352 354 onclick="encloseSelection(' > ', '')" 353 visible="<%=restrictions%>"354 355 /> 355 356 <tbl:button
Note: See TracChangeset
for help on using the changeset viewer.