We see a lot of examples submitted by users but rarely do we see threads about good coding practice. Post below if you have an example which exhibits the "dos and don'ts" of coding in AutoIt.
Why using Dim over Local/Global is not always a good option:
Dim $vVariableThatIsGlobal = "This is a variable that has ""Program Scope"" aka Global."
MsgBox($MB_SYSTEMMODAL, "", "An example of why Dim can cause more problems than solve them.")
MsgBox($MB_SYSTEMMODAL, "", $vVariableThatIsGlobal) ; That looks alright to me as it displays the following text: This is a variable that has "Program Scope" aka Global.
Local $vReturn = SomeFunc() ; Call some random function.
MsgBox($MB_SYSTEMMODAL, $vReturn, $vVariableThatIsGlobal) ; The Global variable ($vVariableThatIsGlobal) changed because I totally forgot I had a duplicate variable name in "SomeFunc".
; This should create a variable in Local scope if the variable name doesn"t already exist.
; For argument sake I totally forgot that I declared a variable already with the same name.
; Well I only want this to be changed in the function and not the variable at the top of the script.
; Should be OK right? Think again.
Dim $vVariableThatIsGlobal = ""
For $i = 1 To 10
$vVariableThatIsGlobal &= $i ; This will return 12345678910 totally wiping the previous contents of $vVariableThatIsGlobal.