I tried the Exec function which can handle only one operator, But in our case user can enter an lenghty expression with more than one operator( AND & or OR |). I hope the exec function will not help us.
If possible let me know any algoritum to do Expression Evaluvation.
Thanks and Regards
Rajesh G
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Is there any Function or Functional Block available to evaluvate a string as shown below
Result:BOOL;
Input_Expression:STRING;
Input_Expression := '1 OR 0 AND 1 OR 0';
Result := ( Should give the result of the Input_expression )
Thanks in advance.
Rajesh G
What you are talking about is an interpreter.
This is a good project for students in first year computer science curriculum.
I don't believe there is an interpreter built into CoDeSys but that doesn't mean you couldn't write one. Although, I can't see the reason for it.
I created a function which will do the process, but the problem is i need to reduce the process time, If the Expression length is big,
Find the attached code for reference.
Equation_Processing_4.pro [283.73 KiB]
in the open source library oscat you can find code for a similar expression engine 'exec' this could be modified quickly to evaluate your statements.
pls get the library at w www.oscat.de w
I tried the Exec function which can handle only one operator, But in our case user can enter an lenghty expression with more than one operator( AND & or OR |). I hope the exec function will not help us.
If possible let me know any algoritum to do Expression Evaluvation.
Thanks and Regards
Rajesh G