# Pythagoras' Theorem Calculator

### By Jonesy44 on Apr 13, 2009

Introduction
Calculates X,Y,or H of a right-angled triangle. dialog included. screenshot below. syntax is /pythag

Screenshot

``````; ===============
; Pythagoras' Theorem Calculator
; Usage:/pythag
; ===============
alias pythag dialog \$iif(\$dialog(pythag),-v,-m) pythag pythag
dialog pythag {
option pixels
title "Pythagoras'"
size -1 -1 175 95
text "X:", 1, 5 7 20 13
text "Y:", 2, 5 28 20 13
text "H:", 3, 5 48 20 13
edit "", 101, 20 5 40 20, autohs
edit "", 102, 20 25 40 20, autohs
edit "", 103, 20 45 40 20, autohs
button "Calculate X", 201, 70 4 100 21, disabled
button "Calculate Y", 202, 70 24 100 21, disabled
button "Calculate H", 203, 70 44 100 21, disabled
edit "", 301, 5 70 143 20, read
button "?", 302, 150 69 20 22
}
on *:dialog:pythag:*:*: {
if (\$devent == edit) { if (\$did isnum 101-103) { did \$iif(\$did(102) isnums && \$did(103) isnum,-e,-b) \$dname 201 | did \$iif(\$did(101) isnum && \$did(103) isnum,-e,-b) \$dname 202 | did \$iif(\$did(101) isnum && \$did(102) isnum,-e,-b) \$dname 203 } }
elseif (\$devent == sclick) {
if (\$did == 302) {
var %x = Pythagoras' Theorem states that the "H^2 = X^2 + Y^2" in right-angled triangles. \$&
This calculator is a simple way to calculate the different angles easily. \$crlf \$+ \$crlf \$+ \$&
Enter two values corresponding to "H", "X", or "Y" and a button will be enabled to calculate the other value (arbitary units). \$&
Click the "Calculate [N]" button and the result will appear at the bottom of the dialog. \$crlf \$+ \$crlf \$+ \$&
"H" \$chr(9) \$chr(9) Hypotenuse \$crlf \$+ "X" and "Y" \$chr(9) Two other sides to the triangle
noop \$input(%x,io,Pythagoras' Theorem Calcualator -  Help)
}
elseif (\$did isnum 201-203) {
did -ra \$dname 301 \$sqrt(\$calc((\$iif(\$did == 203,\$did(101),\$did(103)) ^2) \$iif(\$did == 203,+,-) (\$iif(\$did == 202,\$did(101),\$did(102)) ^2)))
if (!\$did(301)) { noop \$input(Your input values were not correct and returned a false value. Please re-check them,wo,Pythagoras' Theorem Calcualator - Error) }
}
}
}
``````

Jonesy44   -  May 10, 2009

Zeppelin382, the 3,4,5 rule works fine for me, the buttons pop up fine. what version of mirc are you using?

Firstmate, why not?

Firstmate   -  Apr 14, 2009

o.O why do you need a dialog for this.

Zeppelin382   -  Apr 13, 2009

Didn't work for me. I tried using a Pythagorean triple, 3-4-5, and no buttons were enabled. The only button I found was the Help button.

Or maybe it's just me.

Edit: I only used two of them at a time making sure that if I used the 5, it was in the H place.

Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.