Jump to content

Calculator


Recommended Posts

Hello guyz! I need help making a calculator, but instead of

$w = Number(sqrt(12)*(sqrt(15)-sqrt(20))+(2+sqrt(15))^2-42*sqrt(15)/(7*sqrt(3)))
Msgbox (0, "ss", $w )

where I need to edit the script, and then run it, but instead I want to type the number in a InputBox, and then press ok and get the result in a messagebox.

Can anyone tell me how to link the number in the inputbox to the Number(.....) function?

Link to comment
Share on other sites

jsut to make sure i understand the question...do you want to enter an expression in an input box, then use Number() to evaluate the expression?

_____________________________________________________"some people live for the rules, I live for exceptions"Wallpaper Changer - Easily Change Your Windows Wallpaper

Link to comment
Share on other sites

Look in the helpfile at Execute

AutoIt Console written in C#. Write au3 code right at the console :D_FileWriteToLineWrite to a specific line in a file.My UDF Libraries: MySQL UDF Library version 1.6 MySQL Database UDF's for AutoItI have stopped updating the MySQL thread above, all future updates will be on my SVN. The svn location is:kan2.sytes.net/publicsvn/mysqlnote: This will still be available, but due to my new job, and school hours, am no longer developing this udf.My business: www.hirethebrain.com Hire The Brain HireTheBrain.com Computer Consulting, Design, Assembly and RepairOh no! I've commited Scriptocide!
Link to comment
Share on other sites

Hello guyz! I need help making a calculator, but instead of

$w = Number(sqrt(12)*(sqrt(15)-sqrt(20))+(2+sqrt(15))^2-42*sqrt(15)/(7*sqrt(3)))
Msgbox (0, "ss", $w )

where I need to edit the script, and then run it, but instead I want to type the number in a InputBox, and then press ok and get the result in a messagebox.

Can anyone tell me how to link the number in the inputbox to the Number(.....) function?

I don't know if I understood your problem well...

InputBox

--------------------------------------------------------------------------------

Displays an input box to ask the user to enter a string.

InputBox ( "title", "Prompt" [, "Default" [, "password char" [, Width, Height [, Left, Top [, TimeOut]]]]] )

Return Value

Success: Returns the string that was entered.

You get the text in Inputbox with a variable:

$w=inputbox ("Calc","Input your operations","sqrt(12)*(sqrt(15)-sqrt(20))+(2+sqrt(15))^2-42*sqrt(15)/(7*sqrt(3)))")
$w = Number($w)
Msgbox (0, "ss", $w )
Link to comment
Share on other sites

@elgabionline: i tried that too but it only displays the first number in the expression, input 1+1, the output is 1

does the text from the input box have to be formatted in anyway to comply with how Number() works?

edit: TYPO

Edited by Don N

_____________________________________________________"some people live for the rules, I live for exceptions"Wallpaper Changer - Easily Change Your Windows Wallpaper

Link to comment
Share on other sites

I solved the problem,

$w = InputBox ( "Calculator", "Type here" )
$w = Execute ( $w )
MsgBox (0, "ss", $w )

But it works only in Beta Run, if I want to run the script, or compile and then run, it doesen't work....what is the problem?

Edited by Kreatorul
Link to comment
Share on other sites

It doesen't work...I tried a simple operation like 2*3 and the result is 2...

the question was:

Can anyone tell me how to link the number in the inputbox to the Number(.....) function?

my answer was:

with a variable.

Ok, this showld work:

$msg=InputBox ("Calc","Exp[b][/b]ression","2*3")
$msg=Execute ($msg)
MsgBox (0,"Resultado",$msg)
Link to comment
Share on other sites

If this is any help i made a calculator for a game a while back you can most likely hack the code you need from this

#include <GuiConstants.au3>

Global $lvl=Int(64)
Global $fire=Int(64)
Global $light=Int(64)
Global $cold=Int(64)
Global $calfire=Int(64)
Global $callight=Int(64)
Global $calcold=Int(64)
Global $physical=""
Global $CalPA=""
Global $font="verdana"
Global $help= ""
Global $FireBOCL = ""
Global $LightBOCL=""
Global $ColdBOCL = ""


Opt("GUIOnEventMode", 1)

    $mainwindow = GUICreate("D2PA", 200, 160)
    GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSE")
    
    
$okbutton = GUICtrlCreateButton("?", 5, 5, 20,20)
GUICtrlSetOnEvent($okbutton, "help")    

Func help()
    msgbox(0, "How to Make PA", "Physical Absorb cannot be achieved under level 8010" & @LF &"BOCL cannot exceed 8379"& @LF & @LF & "1. Enter level required ie.10000000"& @LF &"2. Enter amount BOCL ie Fire 63"& @LF &"3. Hit enter"& @LF & @LF &"PA (Value) means you have PA"& @LF &"BAD PA means Neg or bad PA"& @LF &"NO PA means you guessed it NO PA"& @LF & @LF &"Sample PA:"& @LF &"Level 10 Million"& @LF &"BOCL Fire 63"& @LF &"BOCL Light 63"& @LF & @LF &"Credits: to Prodigy for the Algorithm"& @LF &"Created By: Nightshiver")
    EndFunc


$lvl = GUICtrlCreateInput("8010", 50, 30, 100, 20)
GUICtrlCreateLabel("Level", 15, 33, 200, 20)
$fire = GUICtrlCreateInput("", 50, 55, 100, 20)
$updown=GUICtrlCreateUpdown($fire)
GUICtrlSetLimit($updown,8379,1)
GUICtrlCreateLabel("Fire", 15, 58, 200, 20)
$light = GUICtrlCreateInput("", 50, 80, 100, 20)
$updown=GUICtrlCreateUpdown($light)
GUICtrlCreateLabel("Light", 15, 83, 200, 20)
$cold = GUICtrlCreateInput("", 50, 105, 100, 20)
$updown=GUICtrlCreateUpdown($cold)
GUICtrlCreateLabel("Cold", 15, 108, 200, 20)



$fireml = GUICtrlCreateLabel("", 155, 58, 25, 25)
$fireml2 = GUICtrlCreateLabel("", 180, 58, 25, 25)

$lightml = GUICtrlCreateLabel("", 155, 83, 25, 25)
$lightml2 = GUICtrlCreateLabel("", 180, 83, 25, 25)

$coldml = GUICtrlCreateLabel("", 155, 108, 25, 25)
$coldml2 = GUICtrlCreateLabel("", 180, 108, 25, 25)


;$lightml = GUICtrlCreateLabel("", 160, 83, 25, 25)
;$coldml = GUICtrlCreateLabel("", 160, 108, 25, 25)

$calc = GUICtrlCreateButton("Enter",15, 130, 150, 20)
GUICtrlSetOnEvent($calc, "calculate")


func calculate()
if GUICtrlRead($lvl) < 8010 then
msgbox(0, "Attention", "You must have a level above 8010 to obtain PA", 10)

Else
$calfire = Mod (((GUICtrlRead($fire)/8) * GUICtrlRead($lvl)), 16777216)
$callight = Mod (((GUICtrlRead($light)/8) * GUICtrlRead($lvl)), 16777216)
$calcold = Mod (((GUICtrlRead($cold)/8) * GUICtrlRead($lvl)), 16777216)

If $calfire > (8388607) Then
    $calfire = (16777216 -$calFire)
      Else
        $calFire = 0
      Endif

If $callight > (8388607) Then
    $callight = ( 16777216 -$callight)
    Else
      $callight = 0
      Endif
;#cs    
If $calcold > (8388607) Then
    $calcold = ( 16777216 -$calcold)
;$calcold = (-16777216) + $calcold
  Else
    $calcold = 0
      Endif
;#ce    
$fireBOCL= GUICtrlRead($fire)
if $fireBOCL > 62 Then
    GUICtrlSetData($fireml,round (GUICtrlRead($fire)/63))
    else
    GUICtrlSetData($fireml,0)
    Endif
GUICtrlSetData($fireml2,Mod (GUICtrlRead($fire),63))

$LightBOCL= GUICtrlRead($Light)
if $LightBOCL > 62 Then
    GUICtrlSetData($Lightml,round (GUICtrlRead($Light)/63))
    else
    GUICtrlSetData($Lightml,0)
    Endif
GUICtrlSetData($Lightml2,Mod (GUICtrlRead($Light),63))


$ColdBOCL= GUICtrlRead($Cold)
if $ColdBOCL > 62 Then
    GUICtrlSetData($Coldml,round (GUICtrlRead($Cold)/63))
    else
    GUICtrlSetData($Coldml,0)
    Endif
GUICtrlSetData($Coldml2,Mod (GUICtrlRead($Cold),63))

CalculatePA()
EndIf
EndFunc



Func CalculatePA()
    
    $physical= Mod (($calcold + $callight + $calfire),16777216)
    
    If  $physical > (8388607) Then
    $physical = ($physical-16777216) /-4
    GUICtrlSetData($CalPA, "PA   (" & $physical &")")
    Else    
      $physical = $physical/(4)
    GUICtrlSetData($CalPA, "BAD PA")
    Endif
    If $physical = 0 then
    GUICtrlSetData($CalPA,"NO PA")
    Endif
    
Endfunc

$CalPA=GUICtrlCreateLabel($physical, 50, 5 ,200, 25)
GUICtrlSetFont (-1,9, 600, 1, $font)


func close()
Exit
endfunc

GuiSetState()
While 1
$msg = GuiGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case Else
;;;
EndSelect
WEnd
Exit
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...