dantay9 Posted March 24, 2009 Share Posted March 24, 2009 (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 March 26, 2009 by dantay9 Link to comment Share on other sites More sharing options...
Valuater Posted March 24, 2009 Share Posted March 24, 2009 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... Valuater 8) Link to comment Share on other sites More sharing options...
dantay9 Posted March 25, 2009 Author Share Posted March 25, 2009 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. Link to comment Share on other sites More sharing options...
Authenticity Posted March 25, 2009 Share Posted March 25, 2009 (edited) 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 March 25, 2009 by Authenticity Link to comment Share on other sites More sharing options...
dantay9 Posted March 26, 2009 Author Share Posted March 26, 2009 Yeah I do need that. Updated the first post. Link to comment Share on other sites More sharing options...
Authenticity Posted March 26, 2009 Share Posted March 26, 2009 (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 March 26, 2009 by Authenticity Link to comment Share on other sites More sharing options...
dantay9 Posted March 26, 2009 Author Share Posted March 26, 2009 (edited) Nice catch. Thanks for pointing that out. Forgot to put in all of your example. Edited March 26, 2009 by dantay9 Link to comment Share on other sites More sharing options...
Authenticity Posted March 26, 2009 Share Posted March 26, 2009 8*(6+4) = "Can't end expression with an operator."Maybe using StringRegExp recursively? (?R) Link to comment Share on other sites More sharing options...
dantay9 Posted March 26, 2009 Author Share Posted March 26, 2009 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? Link to comment Share on other sites More sharing options...
Yashied Posted March 26, 2009 Share Posted March 26, 2009 Pi / Pi = ??? Сan make the screen more, for example 3.14159265358979 / 3.14159265358979 = 1 My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
dantay9 Posted March 26, 2009 Author Share Posted March 26, 2009 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. Link to comment Share on other sites More sharing options...
Yashied Posted March 26, 2009 Share Posted March 26, 2009 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. My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
dantay9 Posted March 26, 2009 Author Share Posted March 26, 2009 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 More sharing options...
Authenticity Posted March 26, 2009 Share Posted March 26, 2009 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 More sharing options...
dantay9 Posted March 26, 2009 Author Share Posted March 26, 2009 Thank you. I see there is a lot more to learn, but this should get me started. Link to comment Share on other sites More sharing options...
dantay9 Posted March 26, 2009 Author Share Posted March 26, 2009 (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 March 26, 2009 by dantay9 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now