Not sure if this is the kind of information you're looking for, but my indentation system is rather inconsistent. I will indent only when I feel the need. I otherwise try to indent according to flow, particularly when it comes to helping others on the forum. Here are a few code samples of mine and from working with others on the forum:
Code: Select all
^6::
CoordMode, Mouse, Screen
x := (A_ScreenWidth / 2)
y := (A_ScreenHeight / 2)
mousemove, x, y
sleep 200
Send, {MButton}
MouseMove, 5, 30, 5, R
Return
^7:: ; update color of controls
Loop 3
{
Gui, Add, Text, % (A_Index=1?"Section":"xs") . " vSample" A_Index, █
Gui, Add, Edit, x+10 vEditor%A_Index% gUpdate_Sample
}
Gui, Show
return
Notice here that I don't indent at all. I could indent the Loop, but I feel like because it's such a short snippet, that I don't need to. I think the braces alone keep it visually distinct.
In this one I don't even do an indent even though I probably should have for the inner loop; it doesn't visually pop out so it can be overlooked:
Code: Select all
^5::
Preset1Key1:=11
Preset1Key2:=12
Preset2Key1:=21
Preset2Key2:=22
varP := {Preset1:{Key1:Preset1Key1,Key2:Preset1Key2},Preset2:{Key1:Preset2Key1,Key2:Preset2Key2}}
Loop 2
{
b_Index:=A_Index
Loop 2
MsgBox % "varP[Preset" B_Index "][Key" A_Index "] = " varP["Preset" B_Index]["Key" A_Index]
}
return
In this one, I don't do any indents except for the "Continue" line, which goes with the If above.
Code: Select all
^3::
FileRead, var, 8 Out of 10 Cats Does Countdown - Episode Guide - All 4 - short.htm
pos:=1
While pos
{
pos:=RegExMatch(var,"originalTitle":"\K.*?"",title,pos)
tit:=SubStr(title,1,-6)
pos:=RegExMatch(var,"summary":"\K.*?"",summary,pos)
subpos:=-1, cast:=""
While subpos
{
subpos:=RegExMatch(summary,"[A-Z][a-z]+\W[A-Z][a-z]+",person,subpos+2)
If (person="Jimmy Carr") || (person="Susie Dent") || (person="Rachel Riley") || (person="Dictionary Corner")
Continue
cast.=person ", "
}
cast:=SubStr(cast,1,-4)
cast:=StrReplace(cast,"`, ","|") ; takes out comma space to leave just normal spaces between first and last name
cast:=StrReplace(cast," ","\") ; replace spaces between first and last name with \
Sort, cast, \ D|
cast:=StrReplace(cast,"|","`, ")
cast:=StrReplace(cast,"\"," ") ; puts back the space between first and last name
SendInput %tit%`t`t%cast%`n
}
return
This code is confusing because the counter++ is indented even though it's not part of the If...
Code: Select all
~LButton::
+LButton::
KeyWait, Shift, D T2 ; times out in 2 seconds
If ErrorLevel ; this becomes true if KeyWait times out
return ; don't do anything more
counter++
Tooltip active %counter%
return
Functions I (sometimes) indent apparently:
Code: Select all
func_01(){
sleep 5000
SendInput first thread finished
}
Code: Select all
for key, attack in arrayI
{
; MsgBox % key "`n" attack "`n`n firstfirst"
match:=false
attackI:=attack
; MsgBox So far
for jey, attackVI in arrayVI
{
; MsgBox % jey "`n" attackVI "`n`n" attackI
If (attackI=attackVI) || ((attackI="Hi Jump Kick") && (attackVI="High Jump Kick"))
{
attackIeasier.push(attackVI " " arrayVI[attackVI])
; MsgBox % attackVI " " arrayVI[attackVI]
}
}
; If match
; attackIeasier.push(attack "--" match)
}
This also shows me trying to do multi-level indentation to keep a flow going, but it's so wack and I feel like I don't have any consistency. After a for loop, do I keep the opening brace on the same column as "for" or tab it over? Well, I do both in that code. Then should the commands be on the same column as the opening brace or a column over? Well, I do both in that code. And then I also don't even tab over for the very last command that runs with the
If match.
My code is laced with MsgBox diagnostics, which in turn make me require braces (like for the
If (attackI=attackVI) || ((attackI="Hi Jump Kick") && (attackVI="High Jump Kick")) part) instead of being able to omit them to do the single line where I push onto an array. But then I just comment out the MsgBox lines as a reminder of what I have already looked at for debugging/diagnosing, instead of removing the MsgBox line and the optional braces.