Hello,

you can formate your formula string and calculate it with the xppCompiler.

Example:

client static real CalculateFormula(str _formula)
{
    real         result;
    xppCompiler xppCompiler = new xppCompiler();
    ;


    if (strlrtrim(_formula) && xppCompiler.compileExpr(_formula))
    {
        result = any2real(xppCompiler.execute());
    }
    else
    {
        result = 0;
    }

    return result;
}



--- In [email protected], "Serge Boomsma" <s.boom...@...> 
wrote:
>
> Hi,
> 
> Maybe you can use something like this:
> 
> static void Job317(Args _args)
> {
>     str function = 'a+b*(c/d)/(d*e)';
>     str nofparms = strkeep(function,'abcdefghijklmnopqrstuvwxyz');
>     str parms;
>     str myjob;
>     int i;
>     ;
> 
>     for (i=1;i<=strlen(nofparms);i++)
>     {
>         if (strscan(parms,substr(nofparms,i,1),1,strlen(parms)+1) == 0)
>         {
>             parms += 'int ' + substr(nofparms,i,1);
> 
>             if (i < strlen(nofparms))
>                 parms += ', ';
>         }
>     }
> 
>     myjob = 'int myfunc(' + parms + '){ return ' + function + ';}';
> 
>     info(myjob);
>     info(strfmt('%1',runbuf(myjob,5,5,5,5,5)));
> }
> 
> Regards,
> 
> Serge Boomsma
> -----Oorspronkelijk bericht-----
> Van: [email protected] 
> [mailto:[email protected]] Namens naveed ali
> Verzonden: dinsdag 3 maart 2009 13:40
> Aan: [email protected]; 
> [email protected]
> Onderwerp: [development-axapta] Mathmatical Expression in ax
> 
> Hi,
>  
>                 I have mathmatical expression like  a+b(c/d)/(d*e).
>    
>   My problem is how to save it in database table and reterive to perform some 
> mathmatical operation.All these varaibles have some fixed values which is 
> stroed in another table.
>  
>            Any help regardig this.
>  
>  
> Regards,
>   
> 
> 
>       
> 
> [Non-text portions of this message have been removed]
> 
> 
> 
> ------------------------------------
> 
> Yahoo! Groups Links
>


Reply via email to