Jump to content

Recommended Posts

Posted (edited)

ok, no more bugs, v 2.0

; Script generated by AutoBuilder 0.5 Prototype (controls [button's, edit's, etc] were created by AutoBuilder)

GuiCreate("AuCalculator    v. 2.0", 300, 350,(@DesktopWidth-257)/2, (@DesktopHeight-303)/2 , 0x04CF0000)
#include <GUIConstants.au3>
Global $Button_13 = GuiCtrlCreateButton("1", 30, 70, 30, 20)
Global $Button_14 = GuiCtrlCreateButton("2", 110, 70, 30, 20)
Global $Button_15 = GuiCtrlCreateButton("3", 190, 70, 30, 20)
Global $Button_16 = GuiCtrlCreateButton("4", 30, 130, 30, 20)
Global $Button_17 = GuiCtrlCreateButton("5", 110, 130, 30, 20)
Global $Button_18 = GuiCtrlCreateButton("6", 190, 130, 30, 20)
Global $Button_19 = GuiCtrlCreateButton("7", 30, 180, 30, 20)
Global $Button_20 = GuiCtrlCreateButton("8", 110, 180, 30, 20)
Global $Button_21 = GuiCtrlCreateButton("9", 190, 180, 30, 20)
Global $Button_22 = GuiCtrlCreateButton("0", 110, 230, 30, 20)
Global $Edit_23 = GuiCtrlCreateEdit("", 40, 20, 170, 20, $ES_AUTOHSCROLL)
Global $Button_24 = GuiCtrlCreateButton("+ Add", 190, 230, 60, 30)
Global $Button_25 = GuiCtrlCreateButton("- Subtract", 20, 230, 60, 30)
Global $Button_26 = GuiCtrlCreateButton("= Equals", 90, 270, 70, 30)
Global $Button_27 = GuiCtrlCreateButton("/ Divide", 20, 270, 50, 30)
Global $Button_28 = GuiCtrlCreateButton("* Multiply", 200, 270, 50, 30)
Global $Menu_29= GUICtrlCreateMenu ("Switch to...")
Global $MenuItem_30= GUICtrlCreateMenuItem ("Conversions", $Menu_29)
Global $Button_31= GUICtrlCreateButton ("Clear", 250, 17)
GuiSetState()
Func Conversions ()
   #include <GUIConstants.au3>
GUICreate ("Conversions")
GUISetState (@SW_SHOW)
$b= GUICtrlCreateButton ("Convert", 5, 30)
$l= GUICtrlCreateLabel ("Feet to inches:", 1, 1)
$i= GUICtrlCreateInput ("Feet here", 55, 33)
$b2= GUICtrlCreateButton ("Convert", 5, 100,)
$l2= GUICtrlCreateLabel ("Inches to feet:", 1, 75) 
$i2= GUICtrlCreateInput ("Inches here", 54, 103)
$b3= GUICtrlCreateButton ("Convert", 5, 170)
$l3= GUICtrlCreateLabel ("Ounces to pounds:", 1, 145)
$i3= GUICtrlCreateInput ("Ounces here", 53, 173, 0x0080)
$b4= GUICtrlCreateButton ("Convert", 5, 233)
$l4= GUICtrlCreateLabel ("Pounds to ounces:", 1, 210)
$i4= GUICtrlCreateInput ("Pounds to ounces", 53, 235)
While 1
   $get= GUIGetMsg ()
   $tmpread2= GUIRead ($i2)
   $tmpread= GUIRead ($i)
   Select
   Case $get= $GUI_EVENT_CLOSE
      ExitLoop
   Case $get= $b
      $tmpread= GUIRead ($i)
      $fee2in= Number ($tmpread*12)
      MsgBox (0, "Result", $fee2in & " Inches")
   Case $get= $b2
      If $tmpread2= 12 Then
         MsgBox (0, "Result", "1 Foot")
      Else 
         $in2fee= Number ($tmpread2/12)
      MsgBox (0, "Result", $in2fee & " Feet")
   EndIf
Case $get= $b3
   $tmpread= GUIRead ($i3)
   If $tmpread= 16 Then
      MsgBox (0, "Result", "1 Pound")
      Else
   $tmpread= GUIRead ($i3)
   $oz2lb= Number ($tmpread/16)
   MsgBox (0, "Result", $oz2lb & " Pounds")
EndIf
Case $get= $b4
   $tmpread= GUIRead ($i4)
   $lb2oz= Number ($tmpread*16)
   MsgBox (0, "Result", $lb2oz & " Ounces")
   EndSelect
   WEnd
EndFunc

Func _Calc($Expr)
 $TmpBatch = @TempDir & "\Calc.bat"
 If NOT FileExists($TmpBatch) Then CreateBatch($TmpBatch)
 $val = RunWait($TmpBatch & ' "' & $Expr & '"', "", @SW_HIDE)
EndFunc

Func CreateBatch($BatchFile)
 $OpenBatch = FileOpen($BatchFile, 2)
    FileWriteLine($OpenBatch, "SET /A VAL=%1")
    FileWriteLine($OpenBatch, "EXIT %VAL%")
 FileClose($OpenBatch)
 EndFunc
   
While 1
    $get = GuiGetMsg()
    Select
    Case $get = -3;Should really use $GUI_EVENT_CLOSE
        ExitLoop
   Case $get= $button_13
      GUICtrlSetData ($edit_23, "1", 1)
   Case $get= $button_14
      GUICtrlSetData ($edit_23, "2", 1)
   Case $get= $button_15
      GUICtrlSetData ($edit_23, "3", 1)
   Case $get= $button_16
      GUICtrlSetData ($edit_23, "4", 1)
   Case $get= $button_17
      GUICtrlSetData ($edit_23, "5", 1)
   Case $get= $button_18
      GUICtrlSetData ($edit_23, "6", 1)
   Case $get= $button_19
      GUICtrlSetData ($edit_23, "7", 1)
   Case $get= $button_20
      GUICtrlSetData ($edit_23, "8", 1)
   Case $get= $button_21
      GUICtrlSetData ($edit_23, "9", 1)
   Case $get= $button_22
      GUICtrlSetData ($edit_23, "0", 1)
   Case $get=$button_24
      GUICtrlSetData ($edit_23, "+", 1)
   Case $get=$button_25
      GUICtrlSetData ($edit_23, "-", 1)
   Case $get=$button_26
$read= GUIRead ($edit_23)
$RetValue = _Calc($read)
GUICtrlSetData ($edit_23, $retvalue)
   Case $get=$button_27
      GUICtrlSetData ($edit_23, "/", 1)
   Case $get=$button_28
      GUICtrlSetData ($edit_23, "*", 1)
   Case $get= $MenuItem_30
      Conversions ()
      ExitLoop
   Case $get= $Button_31
      GUICtrlDelete ($edit_23)
      Global $Edit_23 = GuiCtrlCreateEdit("", 40, 20, 170, 20, $ES_AUTOHSCROLL)
    EndSelect
WEnd
Exit

enjoy :idiot::D

EDIT: i added a clear button too...

ToDo List:

-add the feature to accept non integers...
-more to come! :wacko:
Edited by layer
FootbaG
Posted

also, if theres anything to be added or u want to see done, just post it here along with bugs... tanks a million :idiot:

FootbaG
Posted

also, if theres anything to be added or u want to see done, just post it here along with bugs... tanks a million :idiot:

<{POST_SNAPBACK}>

I thought you said it was bug free. Conversion from pounds to ounces returns 0 ounces for any value, you can enter a non integer value in the input box, and you cannot return to the calc once you enter conversion mode. That's just after a quick test.
Posted (edited)

geez, thanks for spotting that out... it's fixed, i edited it, so now copy and paste it, it should work... i put $tmpread= GUIRead (14) it should be $tmpread= GUIRead ($i4)

lol, thanks for spotting thaty!

emmm, hangh on still fixing the "going back to calculator"...

Edited by layer
FootbaG

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
  • Recently Browsing   0 members

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