Function & Parameter

When every time you call a function, the execution will start from the first statement of the function, and execute all the statements forward until to the end of the function or reach a “Return” statement.

Function can accept to receive parameters and can also return value. The parameter data is passed-in by statement that calling the function, and the function return value will return to position of the calling statement.

If the function needs to return a value, you must define a data type for return value in “Return Type” cell, and use “Return” function to return data of corresponding data type.

If the function need to receive parameter data, must define the parameters with the name & data type in function parameter table. The passing in data of calling statement will fill into corresponding parameter orderly. If the data type of passing in data does not match data type of corresponding parameter, the EPL system will convert the data type to fit it automatically, a Run-Time error will occur if the conversion fails. The function parameter can only be used in its function.

The most common & important function types of EPL are “Event Function” and “User-Defined Function”. The Event Function is provided by EPL libraries, ActiveX controls etc, you can’t change the definition of it. The User-Define Function is provided by user, you can freely change or edit the definition.

Define User-Defined Function

Define User-Defined Function

EPL

An user-defined function contains three important definitions: Function Name, Parameters and Return value.

See picture of example function’s definition as below

EPL

“Function1” is the function’s name, and it returns a Boolean type value, “str” is the first parameter and is String type, “n” is the second parameter and is Integer type.

To define user-defined function parameters must contain these following attributes

 

Parameter Name

Defines the name that will be used in function. Use it same as local variable.

 

Data Type

Data type of parameter should be same as the data passing in or can convert between each other.

 

ByRef

Sets whether the parameter that passing in is by reference. Once this attribute is setted to True, the passing-in data can be changed in the function, allow the function access actual passing-in parameter. If the passing-in data is Array, User-Defined data type, Library-Defined data type, Bin or String type, whatever this attribute is True or not, the data will still pass in by reference. If the data type of passing-in data doesn’t fit the parameter but can convert between each other, such as pass I nteger type data to parameter of Float type, first, the data will convert to Float type automatically, and pass in by reference, in this situation the passing-in data can not be changed by this function whatever this attribute value is.

To check or uncheck this attribute, just click on the item after activate it.

 

Optional

If this attribute is True, calling statement does not need to passing parameter for this parameter position. Mainly for the parameter that has default value, it can also be used in the situation that add new parameters to existed function and do not want to change existed calling statement to fit new added parameter.

To check or uncheck this attribute, just click on the item after activate it.

 

Array

Sets whether parameter can receive array data. If this attribute is True, calling statement must pass a array data, otherwise can’t pass any array data.

To check or uncheck this attribute, just click on the item after activate it.

To delete a function, just select all of the function by mouse or “Shift + Orientation” Keys, and press “Delete” key.

To add parameter to a existed function, just move the inputting focus to function name, and press “Insert” or “Enter Key”.

Function Calling

For calling Event Function, you can write object name plus the event function name, such as

        _MainForm.LButtonDown(100,100,0)

For calling User-Defined Function, you directly write the function name to call it, such as

        FunctionX(100, True, “String”)

Note that, whatever any types of function or any definitions of function, you must write “()” after the function that you called. Such as

         Function1()

even the function1 has no parameters and return value.

Function Address

You can retrieve a function address by two ways, first is using “&” prefix before the function name, such as: &Function1, and second is using GetFunctionAddress() EPL function. The difference between the two ways are, & will return a FunctionAddress type value, and the GetFunctionAddress() will return Integer type value. The function address is very useful when you are using Windows Multithread, see the picture below:

EPL