Re: Evaluate an string.
Posted in 1998
I've done something similar using SQL to process the equation:
let str="select ",l_eqn clipped." from systables where tabid=1"
prepare p_1 from str
declare c1 cursor for p_1
open c1 using ...
.
.
.
You can also use a table to store values of variables and select from that
instead.
create table bibble (
sessid serial,
x integer,
y integer,z integer
)
in 4gl
insert into bibble values(0,l_x,l_y,l_z)let l_sess=sqlca.sqlerrd[2]
let str="select ",l_eqn clipped." from bibble where sessid=",l_sess
prepare p_1 from str
declare c1 cursor for p_1
open c1 using ...
delete from bibble where sessid=l_sess
Art S. Kagel wrote in message <360A7D25.663C@bloomberg.net>...
>Juan Manuel Hernandez del Olmo wrote:
>>
>> Evaluate an string.
>> ------------------------------
>> I would know if it is possible, in 4GL, to evaluate an string. For =
>> example:
>>
>> If I have:
>>
>> let cad='var1+var2*var3'
>>
>> Could I get something like this:
>>
>> num=eval cad
>>
>> So, if var1,var2 and var3 are integers, and its values are 1,2 and 3, the
=
>> value of num would be 6.
>
>Actually 1+2*3 is either 7 or 9 depending on the order of evaluation.
>Using standard rules that would be 7.
>
>Anyway... No you cannot do this. You will have to build your own
>expression parser for this.
>
>Art S. Kagel