Icon Function and Procedure Declarations

Function and procedure declarations must be in the following format:

<Function Declaration> | <Procedure Declaration>;
[<Function Declaration> | <Procedure Declaration>;]

<Function Declaration> =

   function <Function Name> [<Parameters>]: <Type Name>

<Procedure Declaration> =

   procedure <Procedure Name> [<Parameters>]

<Parameters> =

  (<Parameter Declaration>[; <Parameter Declaration>])

<Parameter Declaration> =

   [const] <Parameter Name> [,<Parameter Name>]: <Type Name>

The <Function Name>, <Procedure Name>, <Parameter Name>, and <Type Name> elements must follow the rules for identifiers covered in the Introduction topic, and each function or procedure declaration must be terminated with a semicolon statement terminator (;).

The only difference between a function and procedure is that a function returns a result value, whereas a procedure does not. This means that a function can be used in an expression like a variable or constant, but a procedure can only be used like a statement.

Please see the Function and Procedure Implementations topic for more information on implementing functions and procedures.
Image