Jump to content

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
$degToRad = $pi / 180


if $x = "x" Then
$valx1 = (($y * Sin ($angX * $degToRad)/Sin($angY * $degToRad)))
$valx2 = (($z * Sin ($angX * $degToRad)/Sin($angZ * $degToRad)))
EndIf

if $y = "x" Then
$valy1 = (($x * Sin ($angY * $degToRad)/Sin($angX * $degToRad)))
$valy2 = (($z * Sin ($angY * $degToRad)/Sin($angZ * $degToRad)))
EndIf

if $z = "x" Then
$valz1 = (($x * Sin ($angZ * $degToRad)/Sin($angX * $degToRad)))
$valz2 = (($y * Sin ($angZ * $degToRad)/Sin($angY * $degToRad)))
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

Link to comment
Share on other sites

  • Developers

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

Just define all 6 variables a the top.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
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!!

Link to comment
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)

please help :)

Edited by Charlz
Link to comment
Share on other sites

  • Developers

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

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
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)

please help :)

Hi,

You're missing a closing bracket. :)

Best,
Euler

Link to comment
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.

Best,
Euler

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...