Similarly to other object-oriented programming languages, the following basic syntax rules apply:
The majority of calls will access or modify properties, and you won't usually need additional parameters here. The syntax is
Reference name.
Property.
.
Property
.
Property =
Value
.
Property =
Reference name2.
PropertyAccessors may return a COM object. If you want to use the object, the return value must contain a reference name:
=
Reference name0.
PropertyIf you don't assign a reference name, the type of the object will be returned, but the object itself will not be saved.
It is also possible to assign a COM object to a property:
.
Property =
Reference name1
The general syntax for method calls is
Reference name.
Method. Method calls often require parameters. Any Method can have 0 ... n parameters, any of which may be optional or have default values. there are therefore various ways of passing parameters, by position, name or by a mixture of the two. For a method with 4 parameters, the syntax may be as follows:
.
Method (
Value1,
Value2,
Value3,
Value4)
.
Method (
Value1,
Value2)
.
Method (
Par1:=
Value1,
Par2:=
Value2,
Par3:=
Value3,
Par4:=
Value4)
.
Method (
Value1,
Value2,
Par4:=
Value4)
Methods can return COM objects. If you want to use this object, the return value must contain a reference name:
=
Reference name0.
MethodIf you don't assign a reference name, the type of the object will be returned, but the object itself will not be saved.
It is also possible to pass a COM object to a method:
.
Method = (
Reference name1)If a method or a property returns a COM object, you can call/access a method/property from this object without saving it first. This makes chained calls possible, which can reach deeply buried objects.
Sample chain to access a property:
Reference name.ActiveDocument.NumWords
"ActiveDocument" returns a document, which itself contains the property "NumWords", which returns the number of words in the document as an integer value..
Sample chain to call a method:
Reference name.ActiveDocument.Goto(Line:=123)
"ActiveDocument" returns a document, which has a "Goto" method for positioning the cursor in a document (taking a line number as its parameter).
COM objects can have default functions (properties/methods). Container objects, for example, which manage other objects, often have a default function for selecting contained objects by index. This needs no explicit function call in the command string, but is simply called by passing parameters to the previous method or property. Combined with chained calls, this produces a very flexible system.
Sample call to a default function:
Reference name1 = Reference name0.Documents(1).NumWords
"Documents" returns an array object, whose default method expects the index number of the desired document as a parameter. The example returns the first document in the array as an object. This object then returns its word count as an integer. If the default method werte called "Item", the following call would have the same result:
Reference name1 = Reference name0.Documents.Item(1).NumWords
Given the synatx of function calls, the following rules obviously apply to reference names: