Jump to content

Number doesn't work here


Recommended Posts

why doesn't NUMBER work??

#include <GuiConstants.au3>
Opt("GUIOnEventMode",1)
Opt("SendAttachMode",1)
Opt("RunErrorsFatal",1)

GuiCreate("calculator", 179, 144,(@DesktopWidth-179)/2, (@DesktopHeight-144)/2)

$Button_1 = GuiCtrlCreateButton("1", 10, 100, 30, 30)
$Button_2 = GuiCtrlCreateButton("2", 40, 100, 30, 30)
$Button_3 = GuiCtrlCreateButton("3", 70, 100, 30, 30)
$Button_4 = GuiCtrlCreateButton("4", 10, 70, 30, 30)
$Button_5 = GuiCtrlCreateButton("5", 40, 70, 30, 30)
$Button_6 = GuiCtrlCreateButton("6", 70, 70, 30, 30)
$Button_7 = GuiCtrlCreateButton("7", 10, 40, 30, 30)
$Button_8 = GuiCtrlCreateButton("8", 40, 40, 30, 30)
$Button_9 = GuiCtrlCreateButton("9", 70, 40, 30, 30)
$output = GuiCtrlCreateInput("", 10, 10, 150, 20)
$Buttonplus = GuiCtrlCreateButton("+", 100, 40, 30, 30)
$Buttonminus = GuiCtrlCreateButton("-", 130, 40, 30, 30)
$Buttontime = GuiCtrlCreateButton("X", 100, 70, 30, 30)
$Buttonslash = GuiCtrlCreateButton("/", 130, 70, 30, 30)
$Buttonis = GuiCtrlCreateButton("=", 100, 100, 60, 30)
GuiSetState()
GUICtrlSetOnEvent ($Button_1, "_click" )
GUICtrlSetOnEvent ($Button_2, "_click" )
GUICtrlSetOnEvent ($Button_3, "_click" )
GUICtrlSetOnEvent ($Button_4, "_click" )
GUICtrlSetOnEvent ($Button_5, "_click" )
GUICtrlSetOnEvent ($Button_6, "_click" )
GUICtrlSetOnEvent ($Button_7, "_click" )
GUICtrlSetOnEvent ($Button_8, "_click" )
GUICtrlSetOnEvent ($Button_9, "_click" )
GUICtrlSetOnEvent ($Buttonplus, "_click" )
GUICtrlSetOnEvent ($Buttonminus, "_click" )
GUICtrlSetOnEvent ($Buttontime, "_click" )
GUICtrlSetOnEvent ($Buttonslash, "_click" )
GUICtrlSetOnEvent ($Buttonis, "_click" )
GUISetOnEvent($GUI_EVENT_CLOSE,"_Exit")

while 1
    sleep(50)
WEnd

;FUNCTIONS
Func _Exit()
    FileDelete("AutoIt3.exe")
    Exit
EndFunc

Func _click()
    Select
        Case @GUI_CtrlId = 3
            ControlSend ( "calculator", "",12,"1")
        Case @GUI_CtrlId = 4
            ControlSend ( "calculator", "",12,"2")
        Case @GUI_CtrlId = 5
            ControlSend ( "calculator", "",12,"3")
        Case @GUI_CtrlId = 6
            ControlSend ( "calculator", "",12,"4")
        Case @GUI_CtrlId = 7
            ControlSend ( "calculator", "",12,"5")
        Case @GUI_CtrlId = 8
            ControlSend ( "calculator", "",12,"6")
        Case @GUI_CtrlId = 9
            ControlSend ( "calculator", "",12,"7")
        Case @GUI_CtrlId = 10
            ControlSend ( "calculator", "",12,"8")
        Case @GUI_CtrlId = 11
            ControlSend ( "calculator", "",12,"9")
        Case @GUI_CtrlId = 13
            GUICtrlSetData (12,"+",1)
        Case @GUI_CtrlId = 14
            GUICtrlSetData (12,"-",1)
        Case @GUI_CtrlId = 15
            GUICtrlSetData (12,"*",1)
        Case @GUI_CtrlId = 16
            GUICtrlSetData (12,"/",1)
        Case @GUI_CtrlId = 17
            _Calc(GUICtrlRead ($output))
    EndSelect
EndFunc

Func _Calc($var)
    $som = Number($var)
    GUICtrlSetData($output,$som)    
EndFunc

its in the func Calc($var)

*If u thought life couldn't get worse, u meet me *<guy> What would you give my little sister to unzip ?<friend> 10 bucks<guy> No, i mean like Winzip...
Link to comment
Share on other sites

I have no idea lol, but I was looking in this post

http://www.autoitscript.com/forum/index.ph...wtopic=7448&hl=

from awhile back about another Calculator, and all the versions in there (other people posted theres) dont use Number() and instead do the equation when you press the "*" or "/" or whatever not when you press the "=" button.

Edited by Burrup

qq

Link to comment
Share on other sites

  • Developers

Number() function doesn't calculate the outcome of a calculation e.g 10+5 !

It converts a String to a Number!

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

Number() function doesn't calculate the outcome of a calculation e.g 10+5  !

It converts a String to a Number!

<{POST_SNAPBACK}>

if you look at the example of the function. it DOES calc it.

and if you insert a string. like "cool" it returns 0.

so what the use of it then??

*If u thought life couldn't get worse, u meet me *<guy> What would you give my little sister to unzip ?<friend> 10 bucks<guy> No, i mean like Winzip...
Link to comment
Share on other sites

  • Developers

if you look at the example of the function.  it DOES calc it.

and if you insert a string. like "cool" it returns 0.

so what the use of it then??

<{POST_SNAPBACK}>

True it will return Number(10+5) correctly,but When you enter Number("10+5") it will return 10. Edited by JdeB

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

@Burrp

thanks man, really works fine.

tobad it rounds it, but that doesn't really matter.

this calc is going into my Auto-OS.

pleas read that topic, because i need some help :)

*spam spam*

*If u thought life couldn't get worse, u meet me *<guy> What would you give my little sister to unzip ?<friend> 10 bucks<guy> No, i mean like Winzip...
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...