AutoHotkey Community

It is currently May 27th, 2012, 12:34 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 55 posts ]  Go to page Previous  1, 2, 3, 4
Author Message
 Post subject:
PostPosted: January 10th, 2010, 4:38 pm 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
majkinetor wrote:
Some of us are just silently enjoying :D
I posted because I doubted about it. It still has the most important (practical) problem. The following popular code should produce an error.
Code:
Worksheet := ComObject("Excel.Application").Workbooks.Add.Worksheets(1)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 10th, 2010, 5:50 pm 
Offline
User avatar

Joined: May 5th, 2007, 7:24 pm
Posts: 1240
Location: Seville, Spain
What error? I can't test it because I don't have MS Office.

_________________
fincs
Highly recommended: AutoHotkey_L (see why) (all my code snippets require it)
Formal request to polyethene - I support the unity of the AutoHotkey community
Get SciTE4AutoHotkey v3.0.00 (Release Candidate)
[My project list]


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 11th, 2010, 1:00 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
A simpler one may be:
Code:
val := ComObject("Scripting.Dictionary").Item("test")


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 11th, 2010, 3:57 pm 
Offline
User avatar

Joined: May 5th, 2007, 7:24 pm
Posts: 1240
Location: Seville, Spain
Your code snippet errors on me. Is that the right behavior?
Code:
COM error!
Member not found.

Member name: Item

Press Cancel to exit.

_________________
fincs
Highly recommended: AutoHotkey_L (see why) (all my code snippets require it)
Formal request to polyethene - I support the unity of the AutoHotkey community
Get SciTE4AutoHotkey v3.0.00 (Release Candidate)
[My project list]


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 12th, 2010, 1:02 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
No, it should/better not produce an error.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 13th, 2010, 3:03 am 
Offline

Joined: November 30th, 2008, 1:51 pm
Posts: 73
Hello,

I might miss something, but how about wrapping ComEnumerate/ComEventConnect/ComEventDisconnect in this form:
Code:
comobj.__Enumerate()
comobj.__EventConnect()
comobj.__EventDisconnect()

pros:
1. We do not need to check if the first parameter is a COM object.
2. Reduce the number of built-in functions (which use linear search currently).
cons:
1. The underscores might be annoy?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 13th, 2010, 5:01 pm 
Offline
User avatar

Joined: May 5th, 2007, 7:24 pm
Posts: 1240
Location: Seville, Spain
Built-in functions use binary search (and only when they're being added to the internal function table, the rest uses function pointers) so it's not that of a problem.
Also, Sean (the author of COM.ahk) has released his own take on built-in COM which you can find here.

_________________
fincs
Highly recommended: AutoHotkey_L (see why) (all my code snippets require it)
Formal request to polyethene - I support the unity of the AutoHotkey community
Get SciTE4AutoHotkey v3.0.00 (Release Candidate)
[My project list]


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 13th, 2010, 6:09 pm 
Offline

Joined: November 23rd, 2007, 10:23 am
Posts: 841
Location: ~/.
Sean wrote:
As AHK doesn't have For loop yet, I thought the closest would be:
Code:
Loop, Each, x in y


as a purist, i'd prefer to see

Code:
Loop,Parse,in Y
{
    X := A_ComObj
}


greets
dR

_________________
Image
    All scripts, unless otherwise noted, are hereby released under CC-BY


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 14th, 2010, 10:47 am 
Offline

Joined: May 24th, 2006, 2:49 pm
Posts: 4511
Location: Belgrade
What Parse have to do with iterating the object ?

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 14th, 2010, 12:51 pm 
Offline

Joined: November 7th, 2006, 9:47 pm
Posts: 1934
Location: Germany
If a variable is not given, it could default to a default variable.
Code:
Loop, For, y
MsgBox %A_LoopField%

or to any other variable. If a variable is given, the default variable would not be changed. So that if neccessary nesting would not make any problems. The default variable does exist in loop only and the user defined variable exists outside of variable.
Code:
Loop, For, x in y
MsgBox %x%
MsgBox last x: %x%


Loop, Each could be also used instead of For. To me it does not matter.

_________________
{1:"ahkstdlib", 2:"my libs", 3:"my apps", 4:"my license"}
--> Don't feed the troll! <--


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 55 posts ]  Go to page Previous  1, 2, 3, 4

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 40 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group