Search This Blog

Wednesday, October 24, 2012

Programming trick

Here is some example how you can use sofisticated programming features of AMODIT.
Let's say you want users to choose option from dropdown list and then set some parameters value depending on that choise. Of course you can use bunch of "if-then" statements to achieve it. But it will make code of the rule quite long and not so easy to maintain and to make changes.

Smarter and more tricky way is to put different value of parameters in descriptions of dictionary items. Look at picture below. It is in Polish but focus on syntax of descriptions (column "Opis").

OK, but how to extract value of parameters from it. You can do it using proper Regular Expression:

parameter=RegExp(desc,"param1=(?<param1>[0-9,. ]*)","param1");

It looks pretty complex but saves a lot of code and makes changes easy...

No comments:

Post a Comment