gazai Posted July 15, 2010 Share Posted July 15, 2010 I'm a newbie to AutoIt. I've using other staff for a while (VB, Perl) and starting to learning this unique language, thanks to the great efforts put up for this wonderful platform. I plan to migrate some of my perl codes into AutoIt. I check the function list on Wiki, and, surprisingly, found very limited math functions. I'm talking about simple math functions such as average, standard deviation, percentile. How can I get these functions for AutoIt? Any advice/suggestion is much appreciated. Link to comment Share on other sites More sharing options...
PsaltyDS Posted July 15, 2010 Share Posted July 15, 2010 By writing them. Another option is to search the forum, especially Example Scripts, for things you need. Many of those have already been written and posted. For example: Standard Deviation Calculator Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
LurchMan Posted July 15, 2010 Share Posted July 15, 2010 I'm a newbie to AutoIt. I've using other staff for a while (VB, Perl) and starting to learning this unique language, thanks to the great efforts put up for this wonderful platform. I plan to migrate some of my perl codes into AutoIt. I check the function list on Wiki, and, surprisingly, found very limited math functions. I'm talking about simple math functions such as average, standard deviation, percentile. How can I get these functions for AutoIt? Any advice/suggestion is much appreciated. Simple Average Calc (Took 10 mins to write): Global $aTest[10] = [5,4,6,5,45,32,60,56,2,55] Global $aTest2[11] = [10,5,4,6,5,45,32,60,56,2,55] $rtn = _Avg($aTest, 0) $rtn2 = _Avg($aTest2, 1) ConsoleWrite("AVG1: " & $rtn & " AVG2: " & $rtn2 & @CRLF) ;_Avg ($aVars, [$iIndex = 0]) ;$aVars = Array Input of vars to calc ;$iIndex = 0 or 1 base array ;Sucess: Returns Average ;Failure: Returns -1 if not an array Func _Avg ($aVars, $iIndex = 0) Local $equation = 0 If Not IsArray($aVars) Then Return -1 If $iIndex = 1 Then For $n = 1 To UBound($aVars) - 1 $equation += $aVars[$n] Next Return ($equation / (UBound($aVars) - 1)) Else For $n = 0 To UBound($aVars) - 1 $equation += $aVars[$n] Next Return ($equation / (UBound($aVars))) EndIf EndFunc Dating a girl is just like writing software. Everything's going to work just fine in the testing lab (dating), but as soon as you have contract with a customer (marriage), then your program (life) is going to be facing new situations you never expected. You'll be forced to patch the code (admit you're wrong) and then the code (wife) will just end up all bloated and unmaintainable in the end. Link to comment Share on other sites More sharing options...
gazai Posted July 15, 2010 Author Share Posted July 15, 2010 (edited) Thanks for the advices! It at least gives me a sense what is expected when I need them. When build a slightly complicated algorithm from these home-browned calculations, it may be easily crashed. This will end up spending more time to deal with the 'exceptions', or the "unmaintainable in the end". Edited July 15, 2010 by gazai Link to comment Share on other sites More sharing options...
omikron48 Posted July 15, 2010 Share Posted July 15, 2010 If you code something yourself and only limit it to personal use, you don't really need to invest too much on robustness and error handling since you know to avoid what will break your script. Good coding practice and standards makes easy to reuse and maintain code, although "reusability" in AutoIt may not always be in the traditional sense unless you're one of those that like to build and use a personal "include" library. 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