AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How to translate the "for each" structure into ahk

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
liu2002



Joined: 07 Nov 2006
Posts: 24

PostPosted: Thu Dec 17, 2009 1:10 pm    Post subject: How to translate the "for each" structure into ahk Reply with quote

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
View user's profile Send private message
UncleScrooge



Joined: 14 Apr 2009
Posts: 75
Location: Italy

PostPosted: Thu Dec 17, 2009 1:26 pm    Post subject: Reply with quote

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
View user's profile Send private message AIM Address
Sean



Joined: 12 Feb 2007
Posts: 2462

PostPosted: Thu Dec 17, 2009 1:43 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group