Clearing of Automation Variables

Hi In many examples automation variables are cleared on the end of codeunits with the clear()-function. Is this a need or does Navision clear these variables anyway? Thank you in advance

It depends on the automation. I always do it at the beginning.

Thank you. In my current application I use a XMLDOM-Object. Do you think it should be cleared also at the end?

Taken from page 306 of the “Aplication Designer’s Guide” PDF-Manual (w1w1adg.pdf). Step 5 has the answer to your original question.

quote:

16.3 USING C/SIDE AS AN AUTOMATION CONTROLLER The following description outlines the procedures for using an automation server from C/SIDE. As you will see, there are very few steps required that are specific to C/SIDE (C/AL). Using an automation server consists of five steps:
- 1 Declare the creatable (top-level) interface (class) of the automation server as a variable of type Automation.
- 2 Declare all the other interfaces (classes) as variables of type Automation.
- 3 Use the C/AL function CREATE on the variable declared in step 1. Do not use CREATE on any other variables.
- 4 Use the methods and properties of the automation server in your C/AL code.
- 5 You can CLEAR (destroy) the top-level object if you want. Otherwise, it will be destroyed automatically when the variable goes out of scope.
You will write most of your code during step 4 using the methods and the properties of the automation server. The syntax and the semantics of these methods and properties are documented in the documentation for each automation server. Using these methods and properties in C/AL does not involve any new or changed syntax. The best way to learn how to use automation is to look at actual solutions. The following two sections show you how to use Microsoft Word and Microsoft Excel, respectively.

Thanks!