3 subprogram declarations, Subprogram declarations – Rice Lake iRite IDE User Manual

Page 23

Advertising
background image

920i

Programming Reference - Language Syntax

19

To be the best by every measure

3.3.3

Subprogram Declarations

A subprogram declaration defines the formal parameters, return type, local types and variables, and the
executable code of a subprogram. Subprograms include handlers, procedures, and functions.

Handler Declarations

A handler declaration defines a subprogram that is to be installed as an event handler. An event handler does not
permit parameters or a return type, and can only be invoked by the event dispatching system.

<handler-declaration>:

handler IDENTIFIER ';'

<decl-section>

begin

<stmt-list>

end ';'

;

HANDLER

IDENTIFIER

decl-section

;

stmt-list

;

BEGIN

END

Figure 3-8. Handler Declaration Syntax

Example:

handler SP1Trip;

I : Integer;

begin

for I := 1 to 10

loop

Writeln (1, "Setpoint Tripped!");

if I=2 then

return;

endif;

end loop;

end;

Procedure Declarations

A procedure declaration defines a subprogram that can be invoked by other subprograms. A procedure allows
parameters but not a return type. A procedure must be declared before it can be referenced; recursion is not
supported.

<procedure-declaration>:

procedure IDENTIFIER

<optional-formal-args> ';'

<decl-section>

begin

<stmt-list>

end ';'

;

<optional-formal-args>:

/* NULL */

| <formal-args>

;

<formal-args>:

Advertising
This manual is related to the following products: