To use a class, the program must use the class name as the data type in the section of the definition of local variables. Then, as with simple data types, the name of the variable is set for that class. The name of this variable that represents a class is called instance name. This instance name can then be used to access the class variables and class functions. To make this possible, you must first call the constructor function. This process is called instantiation.

Defining the Instance Name

There are two options to define the instance name for a class:

  1. Only the name of the instance is defined. This requires the explicit call to the constructor function at a later time before the class can be used. This variant is exclusively allowed when using classes within other classes. If classes are used in a PAscript program or in a function, this variant is not allowed.
  2. The instance name is defined at the same time as the constructor function call. If the constructor function is defined with transfer parameters, then all parameters must be transferred during the instancing process. In this case, the instance of this class can be used immediately. This variant is possible everywhere.
className instanceName
className instanceName(parameter_1, ..., parameter_n )

Calling the Constructor Function

The constructor function is called like a type function through the instance name, followed by the : operator and the name of the constructor function (= class name).

instanceName: className()
instanceName: className(parameter_1, ..., parameter_n)
Note The constructor function can also be called multiple times to perform a reinitialization of the class variables. If you access class variables or functions without first calling the constructor function, an error message is issued.

Example

The following example shows a class and various instantiations.

Accessing Class Variables

Class variables are accessed with the instance name, followed by the : operator and the name of the class variable.

programmVariable = instanceName: classVariablesName

Calling Class Functions

Class functions are called with the instance name, followed by the : operator and the name of the function.

[List of return values] = instanceName:classFunctionName(List of the functionparameters)