| View previous topic :: View next topic |
| Author |
Message |
liu2002
Joined: 07 Nov 2006 Posts: 24
|
Posted: Thu Dec 17, 2009 1:10 pm Post subject: How to translate the "for each" structure into ahk |
|
|
Many vbs language can be translated into ahk languge by using the com lib. But I don't know how to deal with the "for each" structure.
Code Example:
| Code: | | for each objNetConn in objEveryColl |
|
|
| Back to top |
|
 |
UncleScrooge
Joined: 14 Apr 2009 Posts: 75 Location: Italy
|
Posted: Thu Dec 17, 2009 1:26 pm Post subject: |
|
|
one way could be:
| Code: |
Loop
{
if (myCollection%A_Index% = "") ;stop at the first empty
Break
.
.
; more code inside the loop
} | whereas you can arrange that myCollection%A_Index% (an array actually) into a more object oriented "thing"
see AutoHotKey_L and COM_L _________________ Intel Centrino @ 2.8GHz
4 GB RAM
WIN XP SP3 |
|
| Back to top |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 2462
|
Posted: Thu Dec 17, 2009 1:43 pm Post subject: |
|
|
| liu2002 wrote: | | Code: | | for each objNetConn in objEveryColl |
| There are various examples around it in the forum, so you only have to reverse it.
| Code: | Enum := COM_Invoke(objEveryColl, "_NewEnum")
; Enum := COM_QueryInterface(Enum, "{00020404-0000-0000-C000-000000000046}") + COM_Release(Enum)*0 ; sometimes indispensable
While COM_Enumerate(Enum, objNetConn)=0
{
...
}
COM_Release(Enum)
| or, with Object support,
| Code: | Enum := objEveryColl._NewEnum
; Enum := COM_QueryInterface(Enum, "{00020404-0000-0000-C000-000000000046}")
While COM_Enumerate(Enum, objNetConn)=0
{
...
}
; COM_Release(Enum)
|
|
|
| Back to top |
|
 |
|