Jump to content

Yet another Calculator


dantay9
 Share

Recommended Posts

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
Link to comment
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

Link to comment
Share on other sites

Link to comment
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.

Link to comment
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. ;]

Link to comment
Share on other sites

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