5.2.1 Long statements

If a long expression cannot be fully displayed when written in a single cell, it can be written in multiple cells according to sequential cells rule, which, in a calculation cell or an executable cell, allows the statement to automatically flow to the next cell each time when it is paused by the character "," or ";" until no such characters appear or the statement reaches the end. For example:

 

A

B

C

1

==["one","two",

"three","four",

"five"]

2

==create(Field1,

Field2,

Field3)

3

==demo.query(

"select NAME,

STATEID from CITIES")

4

==A3.groups(

STATEID;

count(~):Count)

5

>>C5=A4.(

Count)

 

In this cellset, each row is a long statement. A long statement begins with a double equals sign "==" or a double greater-than symbol ">>", telling esProc to write the expression using sequential cells rule. The result of an expression preceded by the double equals sign will be stored in the first cell. Results of A1, A2, A3 and A4 are as follows:

 

 

A5’s long statement assigns value to C5, as shown below:

A long statement can use various functions. Except the last one, all cells should end with ",", ";" or "(".

A long statement makes the structure of an expression in if and case functions clearer:

 

A

B

C

D

1

Position

F

 

 

2

==case(B1,

"C":"Center",

"F":"Forward",

"G":"Guard")

3

Month

7

 

 

4

==if(B3<=3:"Q1",

B3<=6:"Q2",

B3<=9:"Q3",

"Q4")

A2 changes the abbreviations for different positions of the players in a competition to the full words. A4 computes which quarter the month in B3 belongs to.Here’re results of A2 and A4:

 

Besides being contained in a single row, a long statement can also be used in a multi-row code block. In this case, the first cell of the long statement is the master cell, and all the other non-blank cells in the code block are extended cells. For example:

 

A

B

C

1

Air Quality Index

[59,164,50,104,93]

 

2

=B1.(func(A3,~))

 

 

3

func

==if(

A3>300:"Hazardous",

4

 

 

A3>200:"Very Unhealthy",

5

 

 

A3>150:"Unhealthy",

6

 

 

A3>100:"Unhealthy for Sensitive Groups",

7

 

 

A3>50:"Moderate" ,

8

 

 

"Good")

9

 

return B3

 

In this cellset, A3’s subroutine uses a long statement to return the corresponding air quality levels according to the air quality indexes (AQI). B3 is the master cell of the code block accommodating the long statement and C3~C8 covers the extended cells. A2 calls the subroutine to compute the quality levels of a batch of AQI data. Here’s A2’s result:

esProc handles the code block that takes the first cell of the long statement as its master cell as a single statement. An error could arise if the program executes the cells in a code block one by one.