Home pageFind It!Contact JeksJeks documentation

Jeks

 Jeks forum

This forum is dedicated to Jeks.
You may read freely the messages it contents. If you want to write a message or answer to a subject, subscribe to it first.

Subjects Recent messages Login Subscribe

Messages of subject Conditions in expression

guypsia

Location : ANGERS, FRANCE
Member since : Jan 11, 2005
Messages : 1
 Jan 11, 2005 at 8:56 AM
Hello,

I want to use an expression in a formula :

public class function {
public void calcul2() throws com.eteks.parser.CompilationException {
CompiledFunction function3 = parser.compileFunction ("FACT(x) = IF x <= 0 THEN 1 ELSE x * FACT (x - 1)");
double doubleResult2 = function3.computeFunction (new double [] {2,2});
System.out.println("Res=" + doubleResult1);
]

public static void main(String args[]) throws com.eteks.parser.CompilationException {
fonction f = new fonction();
f.calcul2();
}
}

But when I launch the execution, I have got an error :

java -cp jeks.jar;jeksparser.jar;. fonction
Exception in thread "main" com.eteks.parser.CompilationException: Unknown indentifier (IF) at index 10
at com.eteks.parser.FunctionParser.getLexical(FunctionParser.java:505)
at com.eteks.parser.Parser.parseExpression(Parser.java:81)
at com.eteks.parser.FunctionParser.parseExpression(FunctionParser.java:332)
at com.eteks.parser.FunctionParser.compileFunction(FunctionParser.java:201)
at fonction.calcul2(fonction.java:56)
at fonction.main(fonction.java:69)

Why ? Can you help me please ?

Manu

Location : Paris / France
Member since : Apr 29, 2003
Messages : 394
 Jan 11, 2005 at 8:17 PM
You must have created a FunctionParser without specifying its syntax :
FunctionParser parser = new FunctionParser ();

As default syntax doesn't support conditions, you should use instead a syntax like PascalSyntax :
FunctionParser parser = new FunctionParser (new PascalSyntax ());
---
Manu (moderator/modérateur)


Home pageFind It!ContactTop

© Copyrights 1997-2023 eTeks - All rights reserved

JeksJeks documentation