SUPERΒΆ

SUPER is a special variable and is used for object-oriented programming.

SUPER is the pointer of a function block to the basic function block instance from which the function block was generated. The SUPER pointer thus also permits access to the implementation of the methods of the basic function block (basic class). A SUPER pointer is automatically available for each function block.

You can use SUPER only in methods and in the associated function block implementations.

Dereferencing of the pointer: SUPER^

Use of the SUPER pointer: with the help of the keyword SUPER you call a method that is valid in the instance of the basic class or parent class.

Examples

ST:

SUPER^.METH_DoIt();

FBD/CFC/LD

../_images/1a997c88e9c0d0c5c0a8640e01a8dff8

Note

THIS is not yet implemented for the instruction list (IL).

Examples

Use of SUPER and THIS pointers

FUNCTION_BLOCK FB_Base
VAR_OUTPUT
  iCnt : INT;
END_VAR

METHOD METH_DoIt : BOOL
 iCnt := -1;

METHOD METH_DoAlso : BOOL
 METH_DoAlso := TRUE;

FUNCTION_BLOCK FB_1 EXTENDS FB_Base
VAR_OUTPUT
 iBase : INT;
END_VAR

THIS^.METH_DoIt();  //Call of the methods of FB_1
THIS^.METH_DoAlso();

SUPER^.METH_DoIt();   //Call of the methods of FB_Base
SUPER^.METH_DoAlso();
iBase := SUPER^.iCnt;

METHOD METH_DoIt : BOOL
 iCnt := 1111;
 METH_DoIt := TRUE;

PROGRAM PLC_PRG
VAR
 myBase : FB_Base;
 myFB_1 : FB_1;
 iTHIS : INT;
 iBase : INT;
END_VAR

myBase();
iBase := myBase.iCnt;
myFB_1();
iTHIS := myFB_1.iCnt;

See also