Method: Constructor Init()

Every class and class variant definition may implement its own constructor. Constructors are specialized methods, which are invoked automatically during the creation of new objects to complement and finalize their initialization. In Embedded Wizard, constructors are usual methods named explicitly with the identifier Init and declared without any return value and any parameters:

Declaration of a constructor method within the Code Editor window.

Unlike an ordinary method, constructors are invoked by the system only. Calling the Init() method directly from another method is not possible. Moreover, in derived classes when the constructor method is overridden, the system ensures automatically, that starting with the oldest ancestor class every constructor implementation is being called. The usage of the pseudo method super() is not necessary and even not possible.

Add new Init() method

If there is no Init method inherited from an ancestor class, you have to add a new method explicitly:

First add a new method to your class.

Rename the method as Init.

Open the method for editing in Editor window.

Adapt the declaration of the method, so that it has no parameters and its return type is void. See Edit the return data type of the method and Delete a method parameter.

Override inherited Init() method

If there is already an Init method inherited from one of the ancestor classes:

Override this method first.

Then open the method for editing in the Editor window.

Implement the Init() method

Init() methods are implemented similarly as you do with ordinary methods.