Re: Evaluate string expression in if statement?
- From: "Malcolm" <regniztar@xxxxxxxxxxxxxx>
- Date: Wed, 7 Dec 2005 21:19:35 +0000 (UTC)
"Keith Thompson" <kst-u@xxxxxxx> wrote
> Some people have suggested elaborate solutions like using an external
> interpreter. Aside from being way too much work, they're not going to
> work if you want the expression encoded in the string to refer to
> variables in your own program.
>
>> The general application is that I'm in interested in reading if
>> conditionals from a file, not only the conditional variables but the
>> conditional operators as well (the whole phrase).
>
> You might be able to implement an expression evaluator that takes a
> string and evaluates it as an expression, but you'll need to figure
> out how to evaluate variable names within the expression. Mapping
> them to variables in your own program probably doesn't make sense.
>
I think that if you don't understand why a string with the value "myvar"
cannot easily be used to access variable "myvar" in the program, you
probably don't understand enough to mess with expression parsers.
Why do you need these conditional expressions in a file? Is there not some
way of achieving what you want by hard-coding them?
.
- References:
- Evaluate string expression in if statement?
- From: No Such Luck
- Re: Evaluate string expression in if statement?
- From: Keith Thompson
- Evaluate string expression in if statement?
- Prev by Date: Re: [OT]How to get my homework done
- Next by Date: Re: STRING SIZE PROBLEM
- Previous by thread: Re: Evaluate string expression in if statement?
- Next by thread: Re: Evaluate string expression in if statement?
- Index(es):
Relevant Pages
|
|