Share this page 

Evaluate an expressionTag(s): Powerscript


The datastore can be useful to evaluate a numerical expression at run-time. Simply create a minimal datastore and evaluate the expression.
datastore lds_temp

string ls_result
string ls_expession

string ls_err
// a dummy minimal datastore definition
string ls_dsdef = &
'release 6; datawindow() table(column=(type=char(255) name=a dbname="a") )'

lds_temp = CREATE datastore
lds_temp.Create(ls_dsdef, ls_err)
lds_temp.InsertRow(0)

IF Len(ls_err) > 0 THEN
   MessageBox("ds create", ls_err)
ELSE
   ls_expression = "(2 + 7)  / 3"
   ls_result = &
     lds_temp.Describe ( 'evaluate( " ' + ls_expression + ' " ,1)' )
   MessageBox("ds evaluate", ls_result)
END IF
DESTROY lds_temp