<< Click to Display Table of Contents >> Using TextMaker’s methods |
In addition to properties, methods exist and they implement commands that direct TextMaker to execute a specific action.
For example, Application.Quit instructs TextMaker to stop running and Application.Activate lets you force TextMaker to bring its application window to the foreground, if it's covered by windows from other applications:
tm.Application.Activate
Function methods and procedure methods
There are two types of methods: those that return a value to the BASIC program and those that do not. The former are called (in the style of other programming languages) "function methods" or simply "functions", the latter "procedure methods" or simply "procedures".
This distinction may sound a bit picky to you, but it is not because it effects on the notation of instructions.
As long as you call a method without parameters, there is no syntactical difference:
Call as procedure:
tm.Documents.Add ' Add a document to the collection of open documents
Call as function:
Dim newDoc as Object
Set newDoc = tm.Documents.Add ' The same (returning an object this time)
As soon as you access methods with parameters, you need to employ two different styles:
Call as procedure:
tm.ActiveDocument.Tables.Add 3, 3 ' Insert a 3-by-3 table
Call as function:
Dim newTable as Object
Set newTable = tm.ActiveDocument.Tables.Add(3, 3) ' now with a return value
As you can see, if you call the method as a procedure, you may not surround the parameters with parentheses. If you call it as a function, you must surround them with parentheses.