A colleague of mine claims that you cannot early-bind COM objects in AutoIt. Is this true?
Asked
Active
Viewed 969 times
2
-
AutoIt is an interpreted language, so binding is probably done when you call ObjGet or ObjCreate (don't take my word for it though, you'll need to ask [here](http://www.autoitscript.com/forum/forum/7-developer-chat/) for that kind of information). When you say 'early' do you mean when the object is declared or when a property/method is used? – Matt May 05 '11 at 16:10
-
I am a VB programmer so I mean early as you have to add a reference to the library and then declare Dim a as MyLibrary.MyClass etc. – Matt Wilko May 05 '11 at 16:15
-
I've reposted [here](http://www.autoitscript.com/forum/topic/128342-early-binding/), that should get an answer soon. In answer to your last comment... No you can't add references. Everything is done at runtime – Matt May 05 '11 at 16:17
-
1What I want is that a spelling mistake in a method name call is picked up at compile time - rather than 2 months down the line when it is called for the first time and an error is thrown (as happened today!) - Sounds like this isn't possible... – Matt Wilko May 05 '11 at 16:28
1 Answers
3
AutoIt is an interpreted language even when compiled. The actual process of compiling is simply embedding the code in the interpreter (with some preprocessor elements sorted out like includes).
As a result, binding can not be done at compile time, as there is no compile time. This means that the following will compile fine and no error will be detected.
$oShell = ObjCreate("shell.application")
If False Then ConsoleWrite($oShell.LolWut & @LF)
Run that and nothing will happen. $oShell.LolWut will never be evaluated and so there is no error. Try it with the if test executing the statement and you get: The requested action with this object has failed.
Edit: Also note the reply here for more details on implementation.

Matt
- 7,100
- 3
- 28
- 58