I've been thinking - what is the best way to handle loops in ahk script?
For example instead of:
; Collect results 1
Sleep 1000
Addr1 := IE.document.getElementsByClassName("name")[0].innertext
String_Object := StrSplit(addr1, "`,")
If (Substr(Addr1, 1, 2) = "MK")
{
Addr1 := String_Object[2] . "," . Trim(String_Object[3]) . "," . PostCode
MsgBox, %Addr1%
}
Else
{
Addr1 := String_Object[1] . "," . Trim(String_Object[2]) . "," . PostCode
MsgBox, %Addr1%
}
; Collect results 2
Sleep 1000
Addr2 := IE.document.getElementsByClassName("name")[1].innertext
String_Object := StrSplit(addr2, "`,")
If (Substr(Addr2, 1, 2) = "MK")
{
Addr2 := String_Object[2] . "," . Trim(String_Object[3]) . "," . PostCode
MsgBox, %Addr2%
}
Else
{
Addr2 := String_Object[1] . "," . Trim(String_Object[2]) . "," . PostCode
MsgBox, %Addr2%
}
I'd like to do something like this (note this is pseudocode):
j = 0
i = 1
while (i <= 5)
{
Sleep 1000
Addr[i] := IE.document.getElementsByClassName("name")[j].innertext
String_Object := StrSplit(addr[i], "`,")
If (Substr(Addr[i], 1, 2) = "MK")
{
Addr[i] := String_Object[2] . "," . Trim(String_Object[3]) . "," . PostCode
MsgBox, %Addr[i]%
}
Else
{
Addr[i] := String_Object[1] . "," . Trim(String_Object[2]) . "," . PostCode
MsgBox, %Addr[i]%
}
j = j+1
i = i+1
}
Is it possible to accomplish this in AHK?