Home      Downloads             Documentation      FAQ     

Documentation>ETP-Basic reference>Function and procedure declaration

 

Function and procedure declaration

 Procedure declaration without argument :

Procedure ProcedureName :
'...instructions

You haven't to set the end of the procedure. The compiler will take the end of the procedure as the end of or the beginning of the next Module.

Procedure declaration with argument :

Procedure ProcedureName: (Arg1 as TypeArg1, Arg2 as TypeArg2, ...)
'...instructions

Example :

Procedure Hello : (a as Integer, b as Long)
'...instructions


Function declaration:

A function is a procedure which returns a value. It can be called in an expression.

Function FunctionName: (Arg1 as TypeArg1, Arg2 as TypeArg2, ...) as TypeReturnedValue
'...instructions

 

To return the value, you must use the specific Return keyword.

For example, a function that returns twice the integer given :

Function fTwice: (a as Integer) as Integer
Return a*2

Note : The colon (":") after the name of the function are not needed.

After, we will be able to use this function in an expression.

Procedure Hello :
'...
b = 2*4+fTwice(6)
'...

Here, b is 2*4+12 = 20

If you want to declare a function without argument, the syntax is :

Function FunctionName:() as TypeReturneValue

Documentation>ETP-Basic reference>Function and procedure declaration

     
    About ETP Contact Us