Ilansu
4th March 2003, 13:12
Hi all

I'm trying to get a value from a formula .
The formula is stored as a string in a table field:

field.table.form="0.58*((pow(1425,2)*(ASIN((%f-1425)/1425)+0.5*SIN(2*(ASIN((%f-1)))"

How do I get the value of that formula??

I tried the sprintf$() but it doesn't except a string as a parameter.

Thanks
Ilan S

kammie
4th March 2003, 13:29
How about: val( sprintf$(field.value.form, x1, x2) )

RobertB
4th March 2003, 15:52
This will work: long expr.id
double dbl.val.1, dbl.val.2, dbl.ret.val
string my.string(200)


dbl.val.1 = 1600.0
dbl.val.2 = 1.2

| Test (after completing the bracket-pairs)............
my.string = sprintf$("0.58*((pow(1425.0, 2) * (ASIN((%f - 1425.0) / 1425.0) + 0.5 * SIN(2 * (ASIN((%f - 1.0)))))))", dbl.val.1, dbl.val.2)

| Live: assume table field xxtbl987.expr containing your expression
| - also assume 2 different input variable values............
my.string = sprintf$(xxtbl987.expr, dbl.val.1, dbl.val.2)
expr.id = expr.compile(my.string)
dbl.ret.val = d.expr(expr.id) | Returns value 375796.92275
dbl.ret.val = val(my.string) | Returns 0 (but Kammie was on the right track)HTH

evesely
4th March 2003, 15:52
You probably need to run this through the expr.compile command. For example:


long my.expr
double result, val1, val2

my.expr = expr.compile(sprintf$(field.table.form, val1, val2))
result = d.expr(my.expr)


The sprintf$ results in an expression that can be evaluated. The evaluation is done through the expr commands.

Ilansu
6th March 2003, 11:51
Thanks to u all.

expr.compile works fine.

Ilan S