func()

Read(278) Label: 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.

Parameters:

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.

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 functions:

 func()