This chapter lists code examples of handling table sequences and records, including Create an empty table sequence, Judge if it is a record or a table sequence, List fields of a record, Access record fields and assign values to them, Get field number and number of fields, Fill members of a sequence into a record as field values, Get field value from a record by field number, Modify field value in a record by field number, Modify data structure of a table sequence, Replace record field values with fields, insert record(s) at specified position, Row-to-column & column-to-row transpositions, Delete record(s) and Reset table sequence.
|
A |
|
1 |
=create(fld1,fld2,fld3) |
Create an empty table sequence |
2 |
=A1.create() |
Create another empty table sequence using the structure of A1 |
|
A |
|
1 |
[1,2,3] |
|
2 |
=create(fld1).record(A1) |
|
3 |
=ifr(A1(1)) |
false, Judge if it is a record |
4 |
=ifr(A2(1)) |
true, Judge if it is a record |
5 |
=ift(A1) |
false, Judge if it is a table sequence |
6 |
=ift(A2) |
true, Judge if it is a table sequence |
|
A |
|
1 |
=r.fname() |
All fields in the table sequence in which the record resides |
|
A |
|
1 |
=r.Name |
Access by field name |
2 |
=r.#2 |
Access by field number |
3 |
>r.#2="Tom" |
Assignment |
4 |
>r.Name="Tom" |
Assignment |
|
A |
|
1 |
=create(name, gender, job, age) |
|
2 |
=A1.fno(gender) |
2, field number |
3 |
=A1.fno() |
4, number of fields |
|
A |
|
1 |
>r.record([1,2,3]) |
Fill members into the record in order |
|
A |
|
1 |
=r.field(i) |
Get value of the ith field from record r |
|
A |
|
1 |
>r.field(i, x) |
Modify value of the ith field in record r into x |
|
A |
|
1 |
=create(number,name,birthday) |
|
2 |
>A1.rename(number:id) |
Modify a field name |
3 |
>A1.rename(birthday) |
Delete field names |
|
A |
|
1 |
=demo.query("select NAME,EVENT,SCORE from GYMSCORE") |
|
2 |
=A1.group(NAME) |
|
3 |
=A2.new(NAME,~.select@1(EVENT:"BalanceBeam").SCORE:BalanceBeam,~.select@1(EVENT:"Floor").SCORE:Floor) |
Replace record field values with fields |
|
A |
|
1 |
=demo.query("select NAME,EVENT,SCORE from GYMSCORE") |
|
2 |
=A1.pivot(NAME;EVENT,SCORE) |
Row to column |
3 |
=A2.pivot@r(NAME;EVENT,SCORE) |
Column to row |
|
A |
|
1 |
=demo.query("select * from EMPLOYEE") |
|
2 |
=A1.reset() |
Clean up table sequence |