Function Block

Help Contents

Introduction

A Function_Block is a sequence of statements executed in order with state information preserved between executions. You can execute a Function_Block from Program or another function block.

A Function_Block uses the following syntax:

Function_Block name
    variable-declarations

    statement;
    statement;
    ...
    statement;
End_Function_Block

Where:

Example

(* Rising edge detector *)
Function_Block R_TRIG
	Var_Input CLK : Bool; End_Var
	Var_Output Q : Bool; End_Var
	Var M : Bool := False; End_Var

	Q := CLK AND NOT M;
	M := CLK;
End_Function_Block

Further Information

Program Units

To learn about other program units.

Variable Declarations

To learn about variable declarations.

ST Statements

To learn about ST Statements.

Glossary

For the meaning of terms used in Fernhill SCADA.