Jump to content



Photo

Yet another Calculator


  • Please log in to reply
15 replies to this topic

#1 dantay9

dantay9

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 834 posts

Posted 24 March 2009 - 12:53 AM

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.

Attached Files


Edited by dantay9, 26 March 2009 - 10:18 PM.

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





#2 Valuater

Valuater

    www.PayFreeWireless.com

  • MVPs
  • 11,078 posts

Posted 24 March 2009 - 04:12 AM

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)

Posted Image

Clic The Pic!!!


#3 dantay9

dantay9

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 834 posts

Posted 25 March 2009 - 08:00 PM

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.
"Failure is not an option -- it comes packaged with Windows" Gecko Web Browser, Yahtzee!, Toolbar Launcher (like RocketDock)Internet Blocker, Simple Calculator, Local Weather, Easy GDI+ GUI Triangle Solver, TCP File Transfer, Valuater's Autoit WrappersOOP In AutoItUsing Windows XP SP3, 1GB RAM, AMD Athlon Processor @ 2.1 GHzCheck me out at gadgets.freehostrocket.com

#4 Authenticity

Authenticity

    Universalist

  • MVPs
  • 2,619 posts

Posted 25 March 2009 - 11:13 PM

Case $Button[17]     If $Solved = True Then         $Solved = False         GUICtrlSetData($Input, '')     EndIf     Local $aNumbers = StringSplit(GUICtrlRead($Input), '-+\*^')     If Not StringInStr($aNumbers[$aNumbers[0]], '.') Then SetInput('.') . . .


You need this too, right?

Edited by Authenticity, 25 March 2009 - 11:14 PM.


#5 dantay9

dantay9

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 834 posts

Posted 26 March 2009 - 12:07 AM

Yeah I do need that. Updated the first post.
"Failure is not an option -- it comes packaged with Windows" Gecko Web Browser, Yahtzee!, Toolbar Launcher (like RocketDock)Internet Blocker, Simple Calculator, Local Weather, Easy GDI+ GUI Triangle Solver, TCP File Transfer, Valuater's Autoit WrappersOOP In AutoItUsing Windows XP SP3, 1GB RAM, AMD Athlon Processor @ 2.1 GHzCheck me out at gadgets.freehostrocket.com

#6 Authenticity

Authenticity

    Universalist

  • MVPs
  • 2,619 posts

Posted 26 March 2009 - 12:35 AM

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, 26 March 2009 - 12:35 AM.


#7 dantay9

dantay9

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 834 posts

Posted 26 March 2009 - 12:37 AM

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

Edited by dantay9, 26 March 2009 - 12:41 AM.

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

#8 Authenticity

Authenticity

    Universalist

  • MVPs
  • 2,619 posts

Posted 26 March 2009 - 12:57 AM

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

Maybe using StringRegExp recursively? (?R)

#9 dantay9

dantay9

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 834 posts

Posted 26 March 2009 - 01:05 AM

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?
"Failure is not an option -- it comes packaged with Windows" Gecko Web Browser, Yahtzee!, Toolbar Launcher (like RocketDock)Internet Blocker, Simple Calculator, Local Weather, Easy GDI+ GUI Triangle Solver, TCP File Transfer, Valuater's Autoit WrappersOOP In AutoItUsing Windows XP SP3, 1GB RAM, AMD Athlon Processor @ 2.1 GHzCheck me out at gadgets.freehostrocket.com

#10 Yashied

Yashied

    Happy in Moscow

  • MVPs
  • 2,512 posts

Posted 26 March 2009 - 01:06 AM

Pi / Pi = ???

Сan make the screen more, for example

3.14159265358979
/
3.14159265358979
=
1

:D

#11 dantay9

dantay9

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 834 posts

Posted 26 March 2009 - 01:14 AM

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.
"Failure is not an option -- it comes packaged with Windows" Gecko Web Browser, Yahtzee!, Toolbar Launcher (like RocketDock)Internet Blocker, Simple Calculator, Local Weather, Easy GDI+ GUI Triangle Solver, TCP File Transfer, Valuater's Autoit WrappersOOP In AutoItUsing Windows XP SP3, 1GB RAM, AMD Athlon Processor @ 2.1 GHzCheck me out at gadgets.freehostrocket.com

#12 Yashied

Yashied

    Happy in Moscow

  • MVPs
  • 2,512 posts

Posted 26 March 2009 - 01:31 AM

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.

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

#13 dantay9

dantay9

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 834 posts

Posted 26 March 2009 - 01:42 AM

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.
"Failure is not an option -- it comes packaged with Windows" Gecko Web Browser, Yahtzee!, Toolbar Launcher (like RocketDock)Internet Blocker, Simple Calculator, Local Weather, Easy GDI+ GUI Triangle Solver, TCP File Transfer, Valuater's Autoit WrappersOOP In AutoItUsing Windows XP SP3, 1GB RAM, AMD Athlon Processor @ 2.1 GHzCheck me out at gadgets.freehostrocket.com

#14 Authenticity

Authenticity

    Universalist

  • MVPs
  • 2,619 posts

Posted 26 March 2009 - 02:43 AM

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. ;]

#15 dantay9

dantay9

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 834 posts

Posted 26 March 2009 - 07:32 PM

Thank you. I see there is a lot more to learn, but this should get me started.
"Failure is not an option -- it comes packaged with Windows" Gecko Web Browser, Yahtzee!, Toolbar Launcher (like RocketDock)Internet Blocker, Simple Calculator, Local Weather, Easy GDI+ GUI Triangle Solver, TCP File Transfer, Valuater's Autoit WrappersOOP In AutoItUsing Windows XP SP3, 1GB RAM, AMD Athlon Processor @ 2.1 GHzCheck me out at gadgets.freehostrocket.com

#16 dantay9

dantay9

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 834 posts

Posted 26 March 2009 - 10:13 PM

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, 26 March 2009 - 10:18 PM.

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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users