Jump to content
Sign in to follow this  
golfinhu

pass formula from excel to autoit

Recommended Posts

golfinhu

 

Hi, people, how are you?
I'm trying to create an algorithm that passes conditional formulas from excel to Autoit, I was thinking of doing something recursive, but I'm not getting it.

 

#include <Array.au3>

$sString = '=IF(D15="NO",(-K6+(K6*K6-4*K5*K7)^(1/2))/(2*K5),IF(G9="BIG",G14,(-K6+(K6*K6-4*K5*K7)^(1/2))/(2*K5)))'


MsgBox(0,'', _a($sString))

Func _a($sString)
    MsgBox(0, '', $sString)
    Local $sCondition = StringRegExp($sString, "IF\((.+?);", 3)[0]
    Local $aRight = StringRegExp($sString, "IF\(.+?;(.+)\)", 3)

    If StringLeft($aRight[0], 2) <> "IF" Then
        Return 0
    Else
        Return _a($aRight[0])
    EndIf

EndFunc

I wanted something like this:

if $D15 = "NO" then
    (-$K6+($K6*$K6-4*$K5*$K7)^(1/2))/(2*$K5);
elseif $G9 = 'BIG' then
    $G14
else
    (-$K6+($K6*$K6-4*$K5*$K7^(1/2/(2*$K5))));
Endif

 

Remembering that you can have IF inside IF.

 

Is there any simple way to do this?

Thank you very much

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.