Title



I'm trying to figure out how a logic kept in a string can be applied on application runtime. What I mean, let's say that on a form there are several datasets(named ds1,ds2...dsn) several grids and buttons. A button, or a label, or some other GUI element should e visible when the conditions existing in a string are fulfilled. As an example buton1 should be visible when the following condition is achieved

'((ds1.recordcount > 0) or (ds2.eof = true)) and (ds3.FieldByName('blabla').asString ='how the heck should I do this')'
I was looking at the article which RRUZ made for evaluate expressions with LiveBindings, but it is not what I want. I've also looked at different string\math parsers but without success. The last attempt to accomplish this, was by using TJvInterpreter and create scripts which contain the logic, link the script with the objects from the application and evaluate the expression. I'm not sure if it will work.

Is there any other way to accomplish this? I'm asking this, because after googling a lot on this issue I did not found something similar.

Comments

  1. Andrea Raimondi - Think about this, I need to do this dynamically on hundreds of buttons. Conditions can change, and instead of datasets I can have grids, or other custom classes. Basically I need to replace objects in that string and evaluate the conditions.

    ReplyDelete
  2. Radu Barbu, that thing has been thought out so that you can do just that.
    Also, I am pretty sure you can generalise your rules so that you only need a handful to handle the
    various cases.

    How about this: you create a set of utility classes which handle the various visibility
    conditions, then register them with the evaluator.

    At that point, you need to call the right one at the right time. Job done.

    A

    ReplyDelete

Post a Comment