In esProc, constants can be directly stored in cells and be referenced in expressions. For the basic usage of constants, please refer to *esProc Getting Started: Constants*. Actually, when a constant stored in a cell is referenced, it means the value of the cell is used as a variable. The parameters and variables in esProc can be any data types and can be changed freely if necessary. But you should be careful when calling them.

Now let’s learn to use the various parameters in esProc.

## 1. Cell parameters

In esProc, if a cell has value, the cell name can be used directly to reference the cell value in a computational cell or an executable cell. A cell with value can be a constant cell, a computational cell or any other cell which is assigned value by an executable cell. A cell name is composed of the letter for the column and the row number. For example:

A | B | |

1 | 3 | =3*5 |

2 | =A1*B1 | |

3 | =B2 | >B2=3.14 |

4 | =B2/2 |

A1 is a constant cell, B1 is an expression. Both values of A1 and B1 can be used as parameters. The results of B1 and A2 are as follows:

There is neither a constant nor an expression in B2. Thus when A3 calls the cell value of B2, the result is null. In fact the initial value of any cell is **null**.

B3 sets value for cell B2. So when B2 is called in A4, its value becomes **3.14**. And the result of A4 is as follows:

It can be seen that if a cell’s value is not null, its background will be light yellow by default.

In esProc, you can directly use a cell parameter without declaring in advance or defining the parameter name. Moreover, the cell parameters are easy to look up. Therefore they have been widely used.

The following program, for example, uses cell parameters to store and compute the accumulated value:

A | B | C | |

1 | =demo.query(“select * from CITIES”) | ||

2 | |||

3 | for A1 | if A3.POPULATION>500000 | >A2=A2+1 |

4 | else | >B2=B2+1 |

A3 traverses the data of cities. If a city’s population is greater than 500,000, it will be counted in A2; otherwise it will be counted in B2. After computing, the results of A2 and B2 are as follows:

## 2. Program parameters

In a cellset file, you can also define the program parameters, which can be used in the current cellset.

Click **Parameter** in the **Program** menu item on the menu bar, you can view the setting of program parameters:

You can set the parameters used in a cellset file in the **Program parameter** dialog box. A program parameter name is not allowed to contain spacing and signs, or numbers alone; the parameter value, which can be constants of any data type, will be automatically parsed into corresponding data type according to the set value. Please note that expressions cannot be used as program parameters.

If the Set arguments before run option is checked, the Input argument window will pop up before the cellset file is computed:

You can modify the program parameter value before computation starts, or use the default value. To use a program parameter, call it directly by its name:

A | |

1 | =pi*4 |

2 | =arg1+” world!” |

3 | =arg2.(~*~) |

After computing the results ofA1, A2 and A3 are respectively as follows:

A program parameter should be defined before it is used. The use of an undefined program parameter in an expression will make the expression unable to be parsed and thus cause an error.

Since the names of program parameters are user-defined, they are often used to store some constants for computing, such as Pi. In addition, program parameters are used to set those data needed to be modified before computing. For example:

A | B | C | D | |

1 | Big | Small | SAME | |

2 | ||||

3 | for num | =rand(6)+1 | =rand(6)+1 | =rand(6)+1 |

4 | if B3==C3 && B3==D3 | >C2+=1 | ||

5 | else if B3+C3+D3>10 | >A2+=1 |

**num** is a preset program parameter, which sets the number of throwing dice. Count the points of 3 random dices. If the total points are greater than 10, mark them as big and store them in A2; if the total points is less than or equal to 10, mark them as small and store them in B2; if the 3 dices have the same points, store the points in C2 without marking them as big or small. Then set **num** as **100** and perform the computation, results of A2, B2 and C2 are as follows:

In the cellset, the expression >C2+=1 is equal to >C2=C2+1*.* For expressions like **a***=***a***?***x**, they can be abbreviated to** a***?=***x**.** **

## 3. Cellset variables

### 3.1. The use of cellset variables

Besides using cell names directly and calling predefined program parameters, you can also use variables having names, which are called **cellset variables**. Cellset variables are automatically created through value assignment, without declaring in advance. They are valid in the whole cellset once the cellset gets assigned. But the referencing of an unassigned variable will cause errors. For example:

A | B | |

1 | >a=5 | >b=[1,3,2] |

2 | =a+3 | =b.(~+a) |

A1 and B1 define cellset variables ** a** and

**respectively. The variables can be called in A2 and B2. After computing, the results of A2 and B2 are as follows:**

*b*The cellset variables defined in a cellset and their values can be viewed in page **Cellset variable** in the bottom right of the interface:

The program parameters defined by the cellset will also be displayed in this list.

### 3.2. Judge and delete variables

**ifv** function is used in esProc to judge if a variable has been defined. If a defined variable has done its work, it can be removed using **rmv** function. For example:

A | B | |

1 | >a=5 | >b=[1,3,2] |

2 | ||

3 | if ifv(a) | >A2=b.(~+a) |

4 | >rmv(a) | |

5 | if ifv(a) | >B2=b.(~+a) |

The third and fifth lines of code are to assign values to A2 and B2 respectively. Since A4 has removed the variable, only A2 has result

But B2 is empty. The use of **ifv** in A5 for judgment avoids errors in parsing the expression in B5.

## 4. Cellset constants

You can set parameters used repeatedly in cellset computing as the cellset constants, the usage of which is the same as that of the cellet parameters, that is, calling them by their names. But the cellset constants are different from the program parameters in that you can set data types for cellset constants and are not allowed to assign value to them in a cellset, while the program parameters can get assigned.

To view the **cellset constants**, you can click the **Cellset constant** button on the **Tool** menu:

Constants can be various data types, like string, integer, date and sequence, etc. You can directly call them by their names for use:

A | |

1 | =param1+” Smith” |

2 | =round(pi*3*3, 2) |

3 | =param2.sum() |

After computing the results of A1, A2 and A3 are as follows:

## 5. The priority of parameters, variables and constants

In the above you learned the usages of cell parameters, program parameters and cellset constants. But what the situation will be like if parameters, variables or constants of various types are used at the same time?

Let’s first look at the following situation, in which the value of Pi is set as both the cellset constant and the program parameter:

At this point, the cellset is as follows:

A | |

1 | =pi |

2 | >pi=3 |

3 | =pi |

After computing, the results in A1 and A3 are as follows:

As can be seen from this situation, when the namesake cellset constant and program parameter are defined at the same time, the latter has the priority. Thus the value of A1 is **3.14**. But if there is a cellset variable of the same name in the cellset, this cellset variable will gets the priority. Therefore the value of A3 is **3** assigned by A2.

Another situation:

A | |

1 | |

2 | =A1 |

3 | >A1=3 |

4 | =A1 |

As there are no data in A1 originally, the result of A2 is empty. But both the “A1” defined as a cellset constant and that as a program parameter cannot be identified. So cell names cannot be used to set cellset constants and program parameters.

After A3 assigns value to “A1”, the background of cell A1 becomes light yellow. But in the bottom right of the interface there isn’t such a cellset constant as “A1”, which means A3 has actually assigned a value to the cell. Now the data in both A1 and A4 are the same:

Hence, in esProc, the program parameters, cellset constants and variables defined in a cellset should all avoid using names like a cell name.