foot, inches calculator

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
204squares
Posts: 6
Joined: 21 Jul 2018, 13:43

foot, inches calculator

17 Aug 2018, 15:05

Hi Guys, I'm trying to make simple math calculator with feet & inches
for example:
enter 4-2 and 1-8
and it will calculate
4 feet * 12 inches = 48 inches +2 inches = 50 inches
1 feet * 8 inches = 12 inches + 8 inches = 20 inches
and then multiply together = 1,000 square inches

and then calculate square feet & inches
1000 square inches / 144 inches = 6.94 sq.ft.
0.94 * 12 = 11.28
therefore Answer = 6-11 (6 feet 11 inches)
thanks in advance! what am i doing wrong?

i try to make it with function too and no cigar..

Code: Select all

[code=autohotkey file=Untitled.ahk]:*:CA::
Inputbox, length1
Inputbox, length2
length1arr := strSplit(length1, "-")
length2arr := strSplit(length2, "-")
msgbox, % length1arr[1]
inches1 := totalinches(strSplit(length1, "-"), strSplit(length2, "-"))
msgbox, % inches1
inches2 := length2arr.1 * 12 + length2arr.2
answer = inches1 * inches2 * 2
answerinch := mod(answer,12)
answerfeet = %answer% - %answerinch%
answerfeet = answer /12
msgbox, % answerfeet + "-" + answerinch

return

totalinches(feet,inches)
{
Return feet * 12 + inches
}
[/code]
garry
Posts: 3763
Joined: 22 Dec 2013, 12:50

Re: foot, inches calculator

17 Aug 2018, 15:52

didn't checked , just a small example for a GUI

Code: Select all

Gui,1: Font,s12 cRed  ,Lucida Console
setformat,float,0.2
gui, Add, Edit,   x10  y10 w100 h25 vMyvar -vscroll gEdit1
Gui, Add, Edit,   x120 y10 w100 h25 vNewvar right readonly -vscroll, %Newvar%
Gui, add, button, x10  y50 w100 h25 gClear1,CLEAR
Gui, Show, w300 h90, Calculate ( x * 100 )
return
Guiclose:
exitapp

Edit1:
GuiControl,1:, Newvar,
Gui, Submit, NoHide     ; <- GuiControlGet would work here too
Result := (Myvar*100)
GuiControl,1:, Newvar, %result%
return

clear1:
GuiControl,1:, Myvar,
GuiControl,1:, Newvar,
Guicontrol,1:Focus,myvar
return
burque505
Posts: 1734
Joined: 22 Jan 2017, 19:37

Re: foot, inches calculator

17 Aug 2018, 16:43

@204squares, I don't think you accounted for the fact that you have to square the inches also, and I don't think it's very common to see "12 sq.ft. 108 sq.in.", so I haven't done that.
You might look at this code to see if it will help.
Edit: Removed * 2 from answer := 1total * 2total so calculations would be correct. There still isn't any check for not entering the hyphen and an inch value.

Code: Select all

#Persistent

;:*:^!h::
Inputbox, length1, ,First dimension in feet and inches (i.e 12-4)`r`nNote: if zero inches as in 12-0
Inputbox, length2, ,Second dimension in feet and inches (i.e. 6-2)`r`nNote: if zero inches as in 6-0
length1arr := strSplit(length1, "-")
length2arr := strSplit(length2, "-")
1feet := length1arr[1]
1inches := length1arr[2]
2feet := length2arr[1]
2inches := length2arr[2]
1total := (1feet * 12) + 1inches
2total := (2feet *12) + 2inches
answer := 1total * 2total
answerfeet := answer/144
msgbox, The first array is %1feet% feet and %1inches% inches`r`nThe total for the first dimension is %1total% inches`r`nThe second array is %2feet% feet and %2inches% inches`r`nThe total for the second dimension is %2total% inches`r`n`r`nTotal square feet: %answerfeet%

return

Escape::ExitApp
Regards,
burque505
User avatar
EvaUnitTwo
Posts: 1
Joined: 20 Apr 2021, 09:05

Re: foot, inches calculator

20 Apr 2021, 09:09

Seems like a great idea actually. Did you finish it?!

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot], wpulford and 423 guests