Sign in to follow this  
Followers 0
dantay9

Yet another Calculator

16 posts in this topic

#1 ·  Posted (edited)

I know there are a lot of calculators on the forum, but I couldn't find many with anything other than the basic functions. Here is mine. I am still working on more functions like sine, cosine, and tangent, but I thought I'd post it to see if anyone has any ideas more ideas to improve my calculator.

Calculator.au3

Edited by dantay9

[font="Verdana"] [size="2"]"[/size][/font]Failure is not an option -- it comes packaged with Windows"[font="Verdana"][size="2"] Gecko Web Browser[/size][/font][font="Verdana"][size="2"], [/size][/font][font="Verdana"][size="2"]Yahtzee![/size][/font][font="Verdana"][size="2"], Toolbar Launcher (like RocketDock)[/size][/font][font="Verdana"][size="2"]Internet Blocker, Simple Calculator, Local Weather, Easy GDI+ GUI [/size][/font][font="Verdana"][size="2"]Triangle Solver, TCP File Transfer, [/size][/font][font="Verdana"][size="2"]Valuater's Autoit Wrappers[/size][/font][font="Verdana"][size="3"][size="2"][size="2"]OOP In AutoIt[/size][/size][/size][/font][font="Verdana"][size="2"][size="1"]Using Windows XP SP3, 1GB RAM, AMD Athlon Processor @ 2.1 GHzCheck me out at gadgets.freehostrocket.com[/size][/size][/font]

Share this post


Link to post
Share on other sites



oops....

Not Sure what I did here

>Running:(3.3.0.0):C:\Program Files\AutoIt3\autoit3.exe "C:\Program Files\AutoIt3\Examples\My Stuff\trick_old12.au3"

C:\Program Files\AutoIt3\Examples\My Stuff\trick_old12.au3 (252) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.:

ElseIf StringIsXDigit($SplitString[1]) <> 0 And $SplitString[1] <> '.' And StringLeft($Text, 3) <> 'Ans' And Number($SplitString[1]) = 0 Then

ElseIf StringIsXDigit(^ ERROR

->21:07:48 AutoIT3.exe ended.rc:1

+>21:07:49 AutoIt3Wrapper Finished

>Exit code: 1 Time: 80.341

I used two lines of numbers, something like 111111111111111111111111111122222222222222224444444444/2=

***********

Anyways I use OnEvent and GUIGetMsg() all the time, however I do believe that calculators s are more effective using On-Event-Mode

Nice extended calculations... :D

Valuater

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

Thanks for your input. Not sure exactly what you did. I will use OnEvent when I make the menu and maybe for a few other functions.


[font="Verdana"] [size="2"]"[/size][/font]Failure is not an option -- it comes packaged with Windows"[font="Verdana"][size="2"] Gecko Web Browser[/size][/font][font="Verdana"][size="2"], [/size][/font][font="Verdana"][size="2"]Yahtzee![/size][/font][font="Verdana"][size="2"], Toolbar Launcher (like RocketDock)[/size][/font][font="Verdana"][size="2"]Internet Blocker, Simple Calculator, Local Weather, Easy GDI+ GUI [/size][/font][font="Verdana"][size="2"]Triangle Solver, TCP File Transfer, [/size][/font][font="Verdana"][size="2"]Valuater's Autoit Wrappers[/size][/font][font="Verdana"][size="3"][size="2"][size="2"]OOP In AutoIt[/size][/size][/size][/font][font="Verdana"][size="2"][size="1"]Using Windows XP SP3, 1GB RAM, AMD Athlon Processor @ 2.1 GHzCheck me out at gadgets.freehostrocket.com[/size][/size][/font]

Share this post


Link to post
Share on other sites

Yeah I do need that. Updated the first post.


[font="Verdana"] [size="2"]"[/size][/font]Failure is not an option -- it comes packaged with Windows"[font="Verdana"][size="2"] Gecko Web Browser[/size][/font][font="Verdana"][size="2"], [/size][/font][font="Verdana"][size="2"]Yahtzee![/size][/font][font="Verdana"][size="2"], Toolbar Launcher (like RocketDock)[/size][/font][font="Verdana"][size="2"]Internet Blocker, Simple Calculator, Local Weather, Easy GDI+ GUI [/size][/font][font="Verdana"][size="2"]Triangle Solver, TCP File Transfer, [/size][/font][font="Verdana"][size="2"]Valuater's Autoit Wrappers[/size][/font][font="Verdana"][size="3"][size="2"][size="2"]OOP In AutoIt[/size][/size][/size][/font][font="Verdana"][size="2"][size="1"]Using Windows XP SP3, 1GB RAM, AMD Athlon Processor @ 2.1 GHzCheck me out at gadgets.freehostrocket.com[/size][/size][/font]

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

You are not restricting the amount of decimal point per number. If you use 1..2 * 1..9 you won't get any result, not talking about 1.2.3.4 * 1.2.3.4. ;]

Edited by Authenticity

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Nice catch. Thanks for pointing that out. Forgot to put in all of your example.

Edited by dantay9

[font="Verdana"] [size="2"]"[/size][/font]Failure is not an option -- it comes packaged with Windows"[font="Verdana"][size="2"] Gecko Web Browser[/size][/font][font="Verdana"][size="2"], [/size][/font][font="Verdana"][size="2"]Yahtzee![/size][/font][font="Verdana"][size="2"], Toolbar Launcher (like RocketDock)[/size][/font][font="Verdana"][size="2"]Internet Blocker, Simple Calculator, Local Weather, Easy GDI+ GUI [/size][/font][font="Verdana"][size="2"]Triangle Solver, TCP File Transfer, [/size][/font][font="Verdana"][size="2"]Valuater's Autoit Wrappers[/size][/font][font="Verdana"][size="3"][size="2"][size="2"]OOP In AutoIt[/size][/size][/size][/font][font="Verdana"][size="2"][size="1"]Using Windows XP SP3, 1GB RAM, AMD Athlon Processor @ 2.1 GHzCheck me out at gadgets.freehostrocket.com[/size][/size][/font]

Share this post


Link to post
Share on other sites

8*(6+4) = "Can't end expression with an operator."

Maybe using StringRegExp recursively? (?R)

Share this post


Link to post
Share on other sites

I have never used StringRegExp before and it looks really confusing. I looked at the help file, but it didn't help me understand what it was doing. Can you give me an example, so I can learn how to use it?


[font="Verdana"] [size="2"]"[/size][/font]Failure is not an option -- it comes packaged with Windows"[font="Verdana"][size="2"] Gecko Web Browser[/size][/font][font="Verdana"][size="2"], [/size][/font][font="Verdana"][size="2"]Yahtzee![/size][/font][font="Verdana"][size="2"], Toolbar Launcher (like RocketDock)[/size][/font][font="Verdana"][size="2"]Internet Blocker, Simple Calculator, Local Weather, Easy GDI+ GUI [/size][/font][font="Verdana"][size="2"]Triangle Solver, TCP File Transfer, [/size][/font][font="Verdana"][size="2"]Valuater's Autoit Wrappers[/size][/font][font="Verdana"][size="3"][size="2"][size="2"]OOP In AutoIt[/size][/size][/size][/font][font="Verdana"][size="2"][size="1"]Using Windows XP SP3, 1GB RAM, AMD Athlon Processor @ 2.1 GHzCheck me out at gadgets.freehostrocket.com[/size][/size][/font]

Share this post


Link to post
Share on other sites

I was trying to use AUTOHSCROLL but I couldn't get it to work correctly. I think it has something to do with the edit box being readonly.


[font="Verdana"] [size="2"]"[/size][/font]Failure is not an option -- it comes packaged with Windows"[font="Verdana"][size="2"] Gecko Web Browser[/size][/font][font="Verdana"][size="2"], [/size][/font][font="Verdana"][size="2"]Yahtzee![/size][/font][font="Verdana"][size="2"], Toolbar Launcher (like RocketDock)[/size][/font][font="Verdana"][size="2"]Internet Blocker, Simple Calculator, Local Weather, Easy GDI+ GUI [/size][/font][font="Verdana"][size="2"]Triangle Solver, TCP File Transfer, [/size][/font][font="Verdana"][size="2"]Valuater's Autoit Wrappers[/size][/font][font="Verdana"][size="3"][size="2"][size="2"]OOP In AutoIt[/size][/size][/size][/font][font="Verdana"][size="2"][size="1"]Using Windows XP SP3, 1GB RAM, AMD Athlon Processor @ 2.1 GHzCheck me out at gadgets.freehostrocket.com[/size][/size][/font]

Share this post


Link to post
Share on other sites

Share this post


Link to post
Share on other sites

I think enough to limit the number of digits as a simple calculator.

The limit needs to be around 16 because AutoIt doesn't support any more. When I use GUICtrlSetLimit(), it doesn't work. The number of characters aren't limited.


[font="Verdana"] [size="2"]"[/size][/font]Failure is not an option -- it comes packaged with Windows"[font="Verdana"][size="2"] Gecko Web Browser[/size][/font][font="Verdana"][size="2"], [/size][/font][font="Verdana"][size="2"]Yahtzee![/size][/font][font="Verdana"][size="2"], Toolbar Launcher (like RocketDock)[/size][/font][font="Verdana"][size="2"]Internet Blocker, Simple Calculator, Local Weather, Easy GDI+ GUI [/size][/font][font="Verdana"][size="2"]Triangle Solver, TCP File Transfer, [/size][/font][font="Verdana"][size="2"]Valuater's Autoit Wrappers[/size][/font][font="Verdana"][size="3"][size="2"][size="2"]OOP In AutoIt[/size][/size][/size][/font][font="Verdana"][size="2"][size="1"]Using Windows XP SP3, 1GB RAM, AMD Athlon Processor @ 2.1 GHzCheck me out at gadgets.freehostrocket.com[/size][/size][/font]

Share this post


Link to post
Share on other sites

If there was an option to call an embedded code after a successful match of StringRegExp\Replace (there are 256 of those) like (?C1) calling Assign or UDF before replacing or matching any text it'd make it really easy, otherwise it's still available using a few more lines of code by factorizing the equation into "before (" and after ")" and "between )(" heh.

Anyway, I think you can do it exactly as the Windows calculator does by increasing a counter for each opening parentheses and decreasing it if the closing one was pressed, if it's <> 0 then it's not a valid equation.

If you mind taking a look, I've just replaced any inner parentheses with "_" to show that if there was the opportunity to call an embedded code or UDF code while the search and replace is on the way it'll be so convenient:

Dim $sText = "7*(3^((2+7)^(1+1))+0.5)^0.5*(3+1)"
Dim $sPattern = "\(([^()]*|(?R))\)"
Dim $iExtended = 0
Dim $aMatches

Do 
    $sText = StringRegExpReplace($sText, $sPattern, "_")
    $iExtended = @extended
    ConsoleWrite($sText & @LF)
    
    $aMatches = StringRegExp($sText, $sPattern, 3)
    If IsArray($aMatches) Then _ArrayDisplay($aMatches)
Until Not $iExtended

If you'll try "7*(3^((2+7)^(1+1))+0.5)^0.5*(3+1" then you'll end up with an extra "(" which means that running another StringInStr for ( and return value bigger the 0 is an invalid equation. ;]

Share this post


Link to post
Share on other sites

Thank you. I see there is a lot more to learn, but this should get me started.


[font="Verdana"] [size="2"]"[/size][/font]Failure is not an option -- it comes packaged with Windows"[font="Verdana"][size="2"] Gecko Web Browser[/size][/font][font="Verdana"][size="2"], [/size][/font][font="Verdana"][size="2"]Yahtzee![/size][/font][font="Verdana"][size="2"], Toolbar Launcher (like RocketDock)[/size][/font][font="Verdana"][size="2"]Internet Blocker, Simple Calculator, Local Weather, Easy GDI+ GUI [/size][/font][font="Verdana"][size="2"]Triangle Solver, TCP File Transfer, [/size][/font][font="Verdana"][size="2"]Valuater's Autoit Wrappers[/size][/font][font="Verdana"][size="3"][size="2"][size="2"]OOP In AutoIt[/size][/size][/size][/font][font="Verdana"][size="2"][size="1"]Using Windows XP SP3, 1GB RAM, AMD Athlon Processor @ 2.1 GHzCheck me out at gadgets.freehostrocket.com[/size][/size][/font]

Share this post


Link to post
Share on other sites

#16 ·  Posted (edited)

I changed the Error Check function to use StringRegExp(). Tell me what you think. This is my first try at StringRegExp() and I couldn't have done it without Expresso. I am still having trouble with the multilined, scrollable input box. Any help would be appreciated.

Edited by dantay9

[font="Verdana"] [size="2"]"[/size][/font]Failure is not an option -- it comes packaged with Windows"[font="Verdana"][size="2"] Gecko Web Browser[/size][/font][font="Verdana"][size="2"], [/size][/font][font="Verdana"][size="2"]Yahtzee![/size][/font][font="Verdana"][size="2"], Toolbar Launcher (like RocketDock)[/size][/font][font="Verdana"][size="2"]Internet Blocker, Simple Calculator, Local Weather, Easy GDI+ GUI [/size][/font][font="Verdana"][size="2"]Triangle Solver, TCP File Transfer, [/size][/font][font="Verdana"][size="2"]Valuater's Autoit Wrappers[/size][/font][font="Verdana"][size="3"][size="2"][size="2"]OOP In AutoIt[/size][/size][/size][/font][font="Verdana"][size="2"][size="1"]Using Windows XP SP3, 1GB RAM, AMD Athlon Processor @ 2.1 GHzCheck me out at gadgets.freehostrocket.com[/size][/size][/font]

Share this post


Link to post
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
Sign in to follow this  
Followers 0