Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

AutoIt Snippets


  • Please log in to reply
184 replies to this topic

#181 guinness

guinness

    all-consuming swarm in inconspicuous disguise

  • Developers
  • 17,633 posts

Posted 14 October 2014 - 01:42 PM

What on earth?... I do not understand any of that code at all. What are the benefits to all that code over the code I wrote?

I can have multiple instances of the average mean during code execution, whereas your version is only for one. If I want a second instance with your version, then I have to destroy the previous first. Also I am just adding the values together and keeping note of the times the Add() function has been called. No need to store in an array, which is not only a memory hog but less efficient as you ReDim everytime an element is added. Which in the backend creates an new array and copies the old elements across.


Example List: _AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrGeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()LockFile()Mapping CtrlIDsParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...
Updated: 26/09/2014








#182 Morthawt

Morthawt

    aka TutsTeach

  • Active Members
  • PipPipPipPipPipPip
  • 634 posts

Posted 14 October 2014 - 02:26 PM

Well it is the only method I know that I can perform the average with the least amount of code. You have all kinds of things in yours that I don't have a hope of understanding. Including that GUID looking string. You are a developer of AutoIt so I would imagine you know it inside and out, I am not that advanced with the language. I can do a lot and it is rare for me to have an idea and not be able to make something but I ackknowledge there is still a lot to AutoIt that I would likely never get into either because the excess required knowledge per particular usage would be too high, like certain windows API things and WMI etc. But what you wrote in your example is alien to me. lol


Edited by Morthawt, 14 October 2014 - 02:27 PM.


#183 Bluesmaster

Bluesmaster

    Adventurer

  • Active Members
  • PipPip
  • 132 posts

Posted 26 October 2014 - 06:27 PM

just a small one-liner contribution that came along today. Calculates the weekday based on another weekday and the diffrence in  days between them:

(I know you can do it by combining udfs but hey.. geek.gif if you get very very bored you can reverse engineer the math :) )

Mod( Mod( @WDAY + 7 + Mod( $diff , 7 ) , 7 ) + 6 , 7 ) + 1

best regards 

 

Bluesmaster

 

 

 

*Update: there is a much shorter way to do this  (thanks to jchd)

$sourceDay = @WDAY $diff =  22  ; = 22 days in the future ConsoleWrite(   Mod($sourceDay + Mod($diff, 7) + 6, 7) + 1    & @LF)

Edited by Bluesmaster, 30 October 2014 - 05:08 PM.


#184 JLogan3o13

JLogan3o13

    115 and holding

  • MVPs
  • 4,425 posts

Posted 27 October 2014 - 01:14 PM

Bluesmaster, while you explain your approach, the undeclared variable in your snippet may throw newer forum members. It is generally regarded as best practice to include completely runnable code, even for one or two-liners. That way, new folks passing by can take your code and run it, learning from it.

 

 

Edit: Just saw your post in Examples where jchd corrects your methodology. You may want to update your snippet.


Edited by JLogan3o13, 27 October 2014 - 01:37 PM.

If you put a million monkeys on a million keyboards, one of them will eventually write a Java program. The rest of them will write Perl programs.

 

My Scripts: SCCM UDFInclude Source with Compiled Script, Disk Maintenance for Windows XP, "Deal-A-Day" Sites, Windows Firewall UDF


#185 Bluesmaster

Bluesmaster

    Adventurer

  • Active Members
  • PipPip
  • 132 posts

Posted 30 October 2014 - 05:09 PM

update:

 

- runable

- new methodology






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users