This chapter lists code examples about program logic, including Join data in a cellset program into a sequence, Implement switch/case-like structure, Get loop count, Proceed to/exit outer loop, Delete used variables to free memory, Pass multiple parameters to subroutine, Return multiple values by subroutine, Write multi-line comments, and use macro in code.
|
A |
B |
C |
D |
|
1 |
1 |
2 |
3 |
4 |
|
2 |
=[A1:D1] |
|
|
|
|
|
A |
B |
|
1 |
=80 |
|
|
2 |
if A1>=90 |
|
|
3 |
|
> A10="excellent" |
|
4 |
else if A1>=80 |
|
|
5 |
|
> A10="good" |
|
6 |
else if A1>=60 |
|
|
7 |
|
> A10="pass" |
|
8 |
else |
|
|
9 |
|
> A10="fail" |
|
10 |
|
|
good |
|
A |
B |
C |
|
1 |
for |
if #A1==10000 |
break |
|
|
A |
B |
C |
D |
|
1 |
for [3,2,1] |
|
|
|
|
2 |
|
for [5,1,3] |
|
|
|
3 |
|
|
if A1>B2 |
next A1 |
Proceed to the next loop |
4 |
|
|
if A1== B2 |
break A1 |
Exit the outer loop |
|
A |
|
1 |
>var1=to(100) |
|
2 |
=demo.query("select * from EMPLOYEE") |
|
3 |
… |
|
4 |
> var1=null,A2=null |
Delete variable var1 and the value of cell A2 |
|
A |
B |
|
1 |
func |
|
Multiple arguments are arranged in order |
2 |
|
=A1 |
|
3 |
|
=B1 |
|
4 |
|
return B2+B3 |
|
5 |
=func(A1,11,21) |
|
32 |
|
A |
B |
|
1 |
func |
|
|
2 |
|
return [1,2,3,4] |
|
3 |
|
|
|
4 |
=func(A1) |
|
|
|
A |
B |
|
1 |
//This is an example about… |
|
The words from line 1 to line 3 are all comments |
2 |
|
1. Remark 1… |
|
3 |
|
2. Remark 2… |
|
4 |
=1+3 |
|
|
|
A |
B |
|
1 |
[1,2,3,4] |
|
|
2 |
func |
return A1.${A2}() |
|
3 |
func |
return A1.${lower(A3)}() |
|
4 |
=func(A2,"sum") |
|
Return A1.sum() |
5 |
=func(A3,"Avg") |
|
Return A1.avg() |
|
A |
|
1 |
=size.(char(65+rand(26))).concat() |
Parmeter size is passed in from external |
2 |
return A1 |
Return result of A1 |
|
A |
|
1 |
=call(“D:/demo.splx”,5) |
Call subprogram demo.splx to call pass in parameter 5 |
|
A |
B |
|
1 |
=demo.query("select * from EMPLOYEE") |
|
|
2 |
=A1.group(GENDER) |
|
Group by gender |
3 |
fork A2 |
=A3.select(SALARY>10000) |
Get records by specified condition with multiple threads and concatenate results in A3 |