I could REALLY use some help ^_^

Recommended Posts

Heya there!

For starters, I am somewhat new to Autoit, but I can still make a program or two....

However, recently I have tried to make a program which would solve basic Trigonometry problems (so I can give it as a parting gift to some of my friends )

This program is meant to work out the side measurements and angles of triangles in general, using the laws of sine. When I use the "Go" function in SciTe, there were no reported errors, so I compiled the file...

Ran the program, input the values (sufficient to solve for the rest), but an error comes up that one of the variables was not declared, even after I ran through the whole script numerous times....

(a copy of the script is available, in case the following does not work...)

```;TRIG HELPER PROGRAM - SINE
;vars = x,y,z angX, angY,angZ
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Vars
\$x = InputBox ("Trig Helper - Sine","input value of side 'x' (opposite angle X)"&@CRLF&"If there is no value, input 'x'")
\$y = InputBox ("Trig Helper - Sine","input value of side 'y' (opposite angle Y)"&@CRLF&"If there is no value, input 'x'")
\$z = InputBox ("Trig Helper - Sine","input value of side 'z' (opposite angle Z)"&@CRLF&"If there is no value, input 'x'")
\$angX = InputBox ("Trig Helper - Sine","input value of angle 'X' (opposite side x)"&@CRLF&"If there is no value, input 'x'")
\$angY = InputBox ("Trig Helper - Sine","input value of angle 'Y' (opposite side y)"&@CRLF&"If there is no value, input 'x'")
\$angZ = InputBox ("Trig Helper - Sine","input value of angle 'Z' (opposite side z)"&@CRLF&"If there is no value, input 'x'")
;Vars end

MsgBox (1,"Trig Helper - Sine","The following info is what was input"&@CRLF&"side x = "&\$x&" / "&"Angle X = "&\$angX&@CRLF&"side y = "&\$y&" / "&"Angle Y = "&\$angY&@CRLF&"side z = "&\$z&" / "&"Angle Z = "&\$angZ)

;COMPUTATION SECTION
\$pi = 3.14159265358979

if \$x = "x" Then
EndIf

if \$y = "x" Then
EndIf

if \$z = "x" Then
EndIf
;COMPUTATION SECTION END

MsgBox (1,"Trig Helper - Sine","The following has been solved"&@CRLF&"If there are two values for any side/angle, then the non-zero value is the correct one"&@CRLF&"side x = "&\$valx1&" / "&\$valx2&" /~\ "&"Angle X = "&\$angX&@CRLF&"side y = "&\$valy1&" / "&\$valy2&" /~\ "&"Angle Y = "&\$angY&@CRLF&"side z = "&\$valz1&" / "&\$valz2&" /~\ "&"Angle Z = "&\$angZ)

Exit```

Trig helper - Sine ALT.au3

Share on other sites

Quick note;

Any and all help/suggestions are very welcome!

Thanks!!

Share on other sites

The variables \$valx1 and \$valx2 are only set (defined) when the first IF is true.

Just define all 6 variables a the top.

Jos

Live for the present,
Dream of the future,
Learn from the past.

Share on other sites

The variables \$valx1 and \$valx2 are only set (defined) when the first IF is true.

Just define all 6 variables a the top.

Jos

Thanks for the tip! I tried to make all the variables "global" hoping it would work...

But yea, your idea should work!!!

Thanks man!!

Share on other sites

Firstly, you have my gratitude for helping with the previous problem, but alas, another has come up....

I tried to use "Asin" to find the value of an angle, however a snytax error comes up when I do this..

```Global \$angX1 = ASin ((\$x * Sin (\$angZ * \$degToRad)/\$z)
Global \$angX2 = ASin ((\$x * Sin (\$angY * \$degToRad)/\$y)

Global \$angY1 = ASin ((\$y * Sin (\$angZ * \$degToRad)/\$z)
Global \$angY2 = ASin ((\$y * Sin (\$angX * \$degToRad)/\$x)

Global \$angZ1 = ASin ((\$z * Sin (\$angY * \$degToRad)/\$y)
Global \$angZ2 = ASin ((\$z * Sin (\$angX * \$degToRad)/\$x)```

Edited by Charlz

Share on other sites

Firstly, you have my gratitude for helping with the previous problem, but alas, another has come up....

I tried to use "Asin" to find the value of an angle, however a snytax error comes up when I do this..

You could post an example that we can run and demonstartes the error and maybe tell us what error you get?

While you are at it also count the opening and closing brackets.

Edited by Jos

Live for the present,
Dream of the future,
Learn from the past.

Share on other sites

Firstly, you have my gratitude for helping with the previous problem, but alas, another has come up....

I tried to use "Asin" to find the value of an angle, however a snytax error comes up when I do this..

```Global \$angX1 = ASin ((\$x * Sin (\$angZ * \$degToRad)/\$z)
Global \$angX2 = ASin ((\$x * Sin (\$angY * \$degToRad)/\$y)

Global \$angY1 = ASin ((\$y * Sin (\$angZ * \$degToRad)/\$z)
Global \$angY2 = ASin ((\$y * Sin (\$angX * \$degToRad)/\$x)

Global \$angZ1 = ASin ((\$z * Sin (\$angY * \$degToRad)/\$y)
Global \$angZ2 = ASin ((\$z * Sin (\$angX * \$degToRad)/\$x)```

Hi,

You're missing a closing bracket.

Share on other sites

Great, where is the little button that I can press when things just don't seem right?

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share on other sites

whoops ~_~

Just went through the script again (counting the brackets, thnx Euler) and it works perfectly!

Thanks again people!

Share on other sites

whoops ~_~

Just went through the script again (counting the brackets, thnx Euler) and it works perfectly!

Thanks again people!

YW

BTW, using SciTE4AutoIt would help you a lot on such things and many others.

Edited by Euler G.

Create an account

Register a new account