spacer


Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com


home / experts / javascript / column55


OLE Automation in JavaScript

Developer News
Mandrake Linux Founder Back, Virtually
Amazon: We're a Technology Company
Sun Expands MySQL With Closed Source

What is Binding?

Before you can use the properties, methods, and events of an object model, you must first create a programmatic reference to the class containing the properties, methods, or events you wish to use. You do this by declaring a local object variable to hold a reference to the object. You then assign a reference of the object to the local variable.


VB and VBScript use the CreateObject() function to enable and return a reference to an Automation object, while JScript uses the ActiveXObject() constructor function.


Binding refers to the way in which Visual Basic code accesses objects in another application. When you use Automation from one application to work with objects in another application, the application in which you are writing Visual Basic code is the Automation controller. The application whose objects you are working with is the Automation server. When an Automation controller creates an object variable that points to an object supplied by an Automation server, Visual Basic must verify that the object exists and that any properties or methods used with the object are specified correctly. This verification process is known as binding. There are two types of binding with which Visual Basic developers need be concerned: late binding and early binding.


Late Binding

Late binding occurs at run time and is much slower than early binding. In late-bound Automation code, Visual Basic must look up an object and its methods and properties each time it executes a line of code that includes that object. To verify that the object and its methods and properties are specified correctly, Visual Basic must check with the operating system and with the application that supplied the object. Let's take a look at the following Visual Basic code segment:


Dim wdApp As Object
Set wdApp = CreateObject("Word.Application")


The wdApp variable is dimensioned as the generic type of Object. When the variable is declared, Visual Basic doesn't know what type of object it will be, so it must set aside a certain amount of memory for this object. Since the specific object reference is assigned to the general variable, the application has no way of knowing in advance (at design time) what the makeup of the object interface is. Only at runtime does the application get to bind to the interface. Therefore, whenever you refer to the new object, Visual Basic must check the system registry for information on this object.


Early Binding

Early binding is the solution to the problem of slow Automation performance. Early binding occurs at compile time rather than run time, so if your code is saved in a compiled state, binding is complete before the code is even run. When using early binding, Visual Basic doesn't need to continually verify the object information while using the object during the execution of the application.


Not all Automation servers support early binding. The Automation server must provide a type library, containing information about the server's objects, methods, and properties. To take advantage of early binding, you must set a reference to the Automation server's type library. Visual Basic loads the type library into memory, which enables it to recognize these objects and bind them when the code is compiled. The following code segment shows how to create an early bound interface to an object:


Dim wdApp As Word.Application
Set wdApp = CreateObject("Word.Application")


 




http://www.internet.com


Produced by Yehuda Shiran and Tomer Shiran

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

Whitepapers and eBooks

Intel Whitepaper: Comparing Two- and Four-Socket Platforms for Server Virtualization
IBM Solutions Brief: Go Green With IBM System xTM And Intel
HP eBook: Simplifying SQL Server Management
IBM Contest: Are You the Next Superstar? Join the "Search for the XML Superstar" Contest to Find Out
Microsoft PDF: Top 10 Reasons to Move to Server Virtualization with Hyper-V
Microsoft PDF: Six Reasons Why Microsoft's Hyper-V Will Overtake Vmware
Microsoft Step-by-Step Guide: Hyper-V and Failover Clustering
Intel PDF: Quad-Core Impacts More Than the Data Center
Intel PDF: Virtualization Delivers Data Center Efficiency
Go Parallel Article: PDC 2008 in Review
Microsoft PDF: Top 11 Reasons to Upgrade to Windows Server 2008
Avaya Article: Communication-Enabled Mashups: Empowering Both Business Owners and IT
Intel Whitepaper: Building a Real-World Model to Assess Virtualization Platforms
  PDF: Intel Centrino Duo Processor Technology with Intel Core2 Duo Processor
Microsoft Article: Build and Run Virtual Machines with Hyper-V Server 2008
Go Parallel Article: Q&A with a TBB Junkie
IBM Whitepaper: Innovative Collaboration to Advance Your Business
Internet.com eBook: Real Life Rails
IBM eBook: The Pros and Cons of Outsourcing
Internet.com eBook: Best Practices for Developing a Web Site
IBM CXO Whitepaper: The 2008 Global CEO Study "The Enterprise of the Future"
Avaya Article: Call Control XML in Action - A CCXML Auto Attendant
IBM CXO Whitepaper: Unlocking the DNA of the Adaptable Workforce--The Global Human Capital Study 2008
Adobe Acrobat Connect Pro: Web Conferencing and eLearning Whitepapers
HP eBook: Guide to Storage Networking
MORE WHITEPAPERS, EBOOKS, AND ARTICLES
webref The latest from WebReference.com Browse >
Popular JavaScript Framework Libraries: An Overview - Part 3 · Accessing Your MySQL Database from the Web with PHP · Working with the DOM Stylesheets Collection
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Crucial Triples Up With New Three-Channel DDR3 Kits · Meet the Finalists: Excellence in Technology Awards · Tealeaf Offers Insight to Mobile Customer Behavior


Created: January 10, 2000
Revised: January 10, 2000

URL: http://www.webreference.com/js/column55/binding.html