# IF (evaluate a dinamically string expression) (AS2)

**URL:** <https://forum.kirupa.com/t/if-evaluate-a-dinamically-string-expression-as2/323496>\
**Category:** flash\
**Created:** [July 4, 2011, 12:14pm UTC](https://forum.kirupa.com/t/if-evaluate-a-dinamically-string-expression-as2/323496 "2011-07-04T12:14:25Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![aditz\_a](https://avatars.discourse-cdn.com/v4/letter/a/9d8465/32.png) [@aditz\_a](https://forum.kirupa.com/u/aditz_a)\
**Post date:** [July 4, 2011, 12:14pm UTC](https://forum.kirupa.com/t/if-evaluate-a-dinamically-string-expression-as2/323496/1 "2011-07-04T12:14:25Z")

</div>

I need to do a filter and I think the better way is to make an IF statement with a string expression made dinamically by the user. I want the user construct his own filter (by comboboxes) and sent it through a string variable to one and single IF statement.

If is not clear, I want to do something like this:  
e1 = “var1==value1”;  
e2 = “var3==value2”;  
…  
eN = “varN==valueN”;

operator1 = “&&”;  
operator2 = “||”;  
…  
operatorN = “&&”;

par1 = “(”;  
par2 = “)”;  
…  
parN = “)”;

//Remember! e1…eN, operator1…operatorN and par1…parN are transmitted by the user

expression = e1 + operator1 + par1 + e2 + operator2 + e3 + par2 … //and so on…;

if(eval(expression))  
{ … }

but is not working in such simple way :diss::diss:  
Please, help me ! Any ideea ?
