You are here: Core Reference > Coding > Logic > Declaring a Method that is Associated with a Database Object Class

Declaring a Method that is Associated with a Database Object Class

If your program uses a method that is associated with a class of database item (rather than associated with an argument), you need to define the method. To do this, you have to declare the method in the format described in this section.

If you are using a method that is associated with an argument, see Declaring a Method that is Associated with an Aggregate.

When you declare a method for a database item, you have to enclose the declaration in a METHOD keyword and END_METHOD keyword. This has to be entered above the PROGRAM. We recommend that you define the METHOD after the VAR list.

To declare a method, you need to use this format:

METHOD


<Method name> AT %M(<database item>.<method name>): <value type>;


END_METHOD


where the first <Method name> is the name of the method in the program. The <database item> is the path and name of the database item upon which the method will be used, and the second <method name> is the name of the method as it appears in the database. The <value type> is the argument for the method. There may be no arguments, in which case there is no <value type> entry, a single argument as shown, or multiple arguments which are separated by commas (<value type>, <value type>, <value type>).

You may need to use the ClearSCADA Database Schema to locate the name of the method in the database (see Working with the Database Schema in the ClearSCADA Guide to the Database).

Example:

  • METHOD
    • OVR AT %M(AIs.AnalogInp.Override): LREAL;
  • END_METHOD

where METHOD defines the start of the method declaration.

OVR is the name of the override value in the ST program (the name you will use to refer to the method later in the program).

AT %M instructs the program to use a method associated with the database item.

(AIs.AnalogInp.Override) defines the path of the database item upon which the method will be used. In this case, AnalogInp is the name of the database item and it is located in a group named AIs. The .Override is a reference to the name of the method that is to be performed. The name has to be identical to the name of the method as it appears in the ClearSCADA database schema.

LREAL; sets the value of the method to be a long real value, with the semi-colon indicating the end of the value. If the method does not set a value, the value type is not required—you would end the method definition by placing the semi-colon after the closing parenthesis. For example, the Enable Alarms method does not require a value, and so it would be defined as:

  • AccAlrm AT %M(AIs.AnalogInp.EnableAlarms);

END_METHOD defines the end of the method declaration.


ClearSCADA 2015 R2