interpret strings as literals...
Is there a simple way to interpret a string value literally? I have "( object.propery.value <= object2.propery.value )" as user input in a text field and need to come up with the literal boolean value of (object.propery.value <= object2.propery.value). The format is always the same, but I am having trouble with the boolean always being true for a non-empty string.
I tried
private function ifCompare(str:String) : Boolean
{
var params:Object = str.split(" ");
var param1:Object = getValue(params[1]);
var operator:String = params[2];
var param2:Object = getValue(params[3]);
var eval:Boolean = false;
switch(operator)
{
case ">=":
eval = (param1 >= param2);
break;
case ">":
eval = (param1 > param2);
break;
case "<=":
eval = (param1 <= param2);
break;
case "<":
eval = (param1 < param2);
break;
case "==":
case "=":
eval = (param1 == param2);
break;
case "!=":
case "<>":
eval = (param1 != param2);
break;
}
return eval;
}
This returns mixed results and I still have the && and || to deal with. It would be so much easier to be able to say "This is not a string! It is a literal!" Can I do that?