Expression Evaluvation

2009-03-09
2009-03-16
  • RajeshGandhi - 2009-03-09

    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

     
  • ndzied1 - 2009-03-10

    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.

     
  • RajeshGandhi - 2009-03-11

    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]

     
  • hugo - 2009-03-11

    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

     
  • RajeshGandhi - 2009-03-16

    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

     

Log in to post a comment.