Eval

Questions and answers on designing your Servoy solutions, database modelling and other 'how do I do this' that don't fit in any of the other categories

Eval

Postby patrick » Mon Jan 31, 2005 5:01 pm

Hello,

I am currently implementing a module that can be customized for/by my customers without touching the main solution. One problem that I need to solve here is that it has to be integrated into my main solution without me knowing what kind of wild stuff my customers wish to implement.

My idea now is this:

- I have a table with Menu-entries that can be edited by my customers (they can build their own menus in one fixed menu-place)
- One of the columns of the menu table is called "method" and my customers are supposed to enter the name of the method of their module that is to be executed if a users clicks on that menu entry
- I then simply eval() this method and the rest is up to them

While this seems to work fine, I want to make sure that eval() is save to use in cases like this. Half of my navigation logic will be based on this, so I want to make sure...

Thanks!
Patrick
patrick
 
Posts: 3703
Joined: Wed Jun 11, 2003 10:33 am
Location: Munich, Germany

Postby bcusick » Tue Feb 01, 2005 2:32 am

Patrick,

Sure - eval can be used like this. The one caution about using eval() is that it can't be compiled, so it must be evaluated "on the fly" - and thus might be a bit "slower" in performance (not enough to really notice, but there is it slower than writing the code so it will compile into bytecode).

If you can live with that - then you should be just fine. I've used a similar technique and it works very well.
Bob Cusick
bcusick
 
Posts: 1255
Joined: Wed Apr 23, 2003 11:27 pm
Location: Thousand Oaks, CA USA

Postby patrick » Tue Feb 01, 2005 9:54 am

Thanks Bob!
patrick
 
Posts: 3703
Joined: Wed Jun 11, 2003 10:33 am
Location: Munich, Germany


Return to Programming with Servoy

Who is online

Users browsing this forum: No registered users and 2 guests