• esProc
Tutorial
Function Reference
User Reference
External Library Guide
Data File Tool Manual
DQL Tutorial
Cluster Server Manager Manual
SPL WIN Manual
• YModel
User Reference
JSON-style Parameter Guide
• ReportLite
User Reference
• Official Website

# func()

Here’s how to use func() function.

## func()

Description:

Call a subroutine.

Syntax:

func(c,xi)

Note:

You can call a subroutine from any cell as required once defining it in a program cellset. The function calls a subroutine starting from master cell c and, in the meantime, passes in parameter xi, if the parameter exists, and assigns it to c. If there are multiple parameters xi, like x1 , x2 , x3,... xi,  they will be assigned to cells in a row from left to right starting from cell c. Return the return value defined by the subroutine after the call is completed.

Parameter:

 c The master cell of a subroutine; it is usually the cell where the func is located xi The parameter used in a subroutine, which can be a numerical value, a sequence, or other types of value; use comma to separate them if there are multiple parameters

Option:

 @i Increase performance by not using recursive invocation; by default, the function will copy cells to enable recursive invocation @m Enable macro invocation when the func function body only consists of an expression, whose variables must not be changed

Return value:

The return value of the subroutine

Example:

 A B 1 func Define a subroutine. Return sum of members of the passed-in sequence parameter. 2 return A1.sum() 3 =func(A1,[1,2,3]) Calling method; the return value is 6.

 A B 1 func Enter parameters in continuous cells from left to right, that is, 8 for A1 and 3 for B1. Return product of the two parameters. 2 return A1*B1 3 =func(A1,8,3) Call A1’s subroutine and return 24.

## func …{return x i }

Description:

Define a function block.

Syntax:

func

{return xi}

Note:

The function defines a function block, which may or may not return a result after computation. The function block (subroutine) begins with the starting characters func and covers a cell range where the master cell is the one holding the func. The return statement is used to return the function's result and terminate the execution of the function block. The subroutine will by default return the value of the last calculation cell if no return statement appears during execution.

Return value:

The result of the function block.

Example:

 A B 1 func Define a subroutine where the parameter passed in is a sequence and that returns the sum of members of the sequence. 2 return A1.sum()

Related function:

## func fn(arg,…)

Description:

Define a named function block.

Syntax:

func fn(arg,...)

Note:

The function defines a function block (a subprogram) whose name is fn while specifying parameters that will not be entered into cell, and returns a result or not. The return statement is used to return the result set of executing the function and close the function block. When the subprogram is successfully executed, value of the last cell in the function block will be returned by default if there isn’t a return statement.

Parameter:

 fn Function name arg,… Specified parameters

Return value:

Result of executing a program

Example:

 A B 1 func test(num1,num2) Define a subprogram, whose parameters passed in is a sequence, and return the concatenation of members of the sequence. 2 return num1*num2

Related function: