Next: 2.6 Releasing Objects
Up: 2. Tutorial
Previous: 2.4 Getting Help about
Contents
2.5 Methods and Properties
After creating an object, the next step is to use it. This is primarily done through method calls and property accesses. To call a method of the object, do it as if the method was a function stored in a Lua table whose key is the method name:
-- Here we call the method 'Show' of the COM object
myobj:Show()
-- A method with a return value
result = myobj:CheckState()
-- A method with parameters
file = myobj:LoadFile("test.xyz", 1)
-- A method with output values
x, y = myobj:UpdatePosition(x, y)
To read or write simple properties, one must simply use them as if they were normal table fields.
-- Reading properties value1 = obj1.Value value1 = obj2.Value -- writing a property obj3.Value = value1 + value2
Automation includes support to parametrized properties. These can be accessed (or written) using accessor functions.
value = obj:getMatrixValue(1,1) value = value*0,125 obj:setMatrixValue(1, 1, value)
Fabio Mascarenhas de Queiroz 2005-01-07