You are here: Core Reference > Coding > Logic > Edit an ST Library

Edit an ST Library

You need to edit each ST Library so that it contains the code that defines a user function block.

To edit an ST library:

  1. Display the Database Bar (see Display an Explorer Bar in the ClearSCADA Guide to ViewX and WebX Clients).
  2. In the Database Bar, right-click on the ST library item to display a context sensitive menu.
  3. Select the Edit Structured Text Library option to display the ST Library Editor window. This window works in the same way as the ST Program window—it has a section for entering the ST code and a compiler section.
  4. Enter the ST code for the custom function block. Begin the code by using the FUNCTION_BLOCK definition, then define the VAR_INPUTS, VAR_OUTPUTS, and expressions in blocks in the same way as any other ST program (see Compiling an ST Program or ST Library).

    NOTE: An example of the code for an ST Library is included at the end of this section.

  5. Use the compile tools to check the syntax of the ST Library code (see Compiling an ST Program or ST Library).
  6. Save the ST Library.

The code in an ST library can be used by multiple Logic programs. The code needs to be created only once and can be included in as many Logic programs as required.

Example:

The following ST code is used in an ST Library to provide the Logic that converts a value in Celsius to a value in Fahrenheit:

  • FUNCTION_BLOCK Celsius_to_Fahrenheit
  • VAR_INPUT
  • Celsius:REAL;
  • END_VAR
  • VAR_OUTPUT
  • Fahrenheit:REAL;
  • END_VAR
  • Fahrenheit := ((Celsius*9/5) + 32);
  • END_FUNCTION_BLOCK

The Celsius to Fahrenheit conversion only needs to be created once (in an ST Library), and it can be included in as many Logic programs as required, for example:


  • PROGRAM ConvertLoad
  • VAR
  • c : Celsius_to_Fahrenheit;
  • END_VAR
  • VAR
  • TEMPINC AT %I(.TempC) :REAL;
  • TEMPINF AT %Q(.TempF) :REAL;
  • END_VAR
  • c(Celsius := TEMPINC, Fahrenheit => TEMPINF);
  • END_PROGRAM

For more information, see see Reference an ST Library or Function Block Library in a Logic Diagram and Reference an ST Library or Function Block Library in an ST Program.


ClearSCADA 2015 R2