# pass formula from excel to autoit

## Recommended Posts

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

## Create an account

Register a new account