Late binding operation
The ~ operation is used for late binding. This operation has a lot in common with the . operator (used to access a field value or method call); however, at compile time it is sometimes difficult to define all methods and fields of an object, whereas while executing a program a particular method of an object is called for being assigned a field/method name, types and values of parameters. The late binding operation is actually applied for COM objects.
An object identifier is the left-hand operand of the ~ operation, that is used for maintaining late binding; the right-hand operand is a field/method name, that is used either for setting up a property (e.g. excapp~Visible) or for calling a method (e.g. excapp~Cells(3,2)).
An object can maintain the following kinds of late binding:
- elementary method call excapp~Quit, with/without parameters;
- set value excapp~Cells( 3, 2 ) = "Hello World!";
- get value vis = uint( excapp~Visible );
- call chain excapp~WorkBooks~Add, equals the following expressions
tmpobj = excapp~WorkBooks
tmpobj~Add
A shortcoming of late binding is that the compiler cannot check if either fields/methods or types are specified properly; it causes problems for troubleshooting.
Have a look at the example of using late binding, where the COM library is applied.
include { "olecom.ge"}
...
oleobj excapp
excapp.createobj( "Excel.Application", "" )
excapp.flgs = $FOLEOBJ_INT
excapp~Visible = 1
excapp~WorkBooks~Add
excapp~Cells( 3, 2 ) = "Hello World!"