For processing tabular data LabPP_Automat provides a powerful tool ts_table(...).
To use it you must first create an object of type "ts_table" with the creation of the object.
This function returns an integer. This so-called object handle.
Pointing it out when referring to the functions ts_table(...) we indicate how an instance of the object we want to act on.
Here we create an object of type ts_table:

    int TableDescr1;  // definition variable type "integer".
    object("create","ts_table",TableDescr1);  // create object type ts_table" and write his descriptor into variable ableDescr1
    // This place we work with ower instatce of object ts_table->
    // <-
    object("delete",TableDescr1); // where we not needed this instatce, delete him, by his descriptor.

Through the use of descriptors we can work simultaneously with a large number of table objects. And this, in turn, gives us the ability to create reports and processing the incredible complexity simple, convenient and understandable.

To work with instance of an object "ts_table" function is used

ts_table(int descriptor, string directive, ....);

The essence of the Directive defines the string list, and the value of the following further arguments.

add_column   add column to table
set_first_key   specify column, by checking unicity of rows (wery usefull)
add_row   add row

add row with summ number values on other columns, if value of unify column are same with already present row

sort   do sort table rows by specified column
select_row   specify row to set it as current
search   fast search row by value in column
get_value_of   get value from specified column from current row
get_rows_count   get number of rows in table
get_columns_count   get number of columns in table


Columns can be string or numeric.
The command format is:

ts_table(int descriptor, "add_column", int columnnumber, string columnname);

descriptor - the handle of the object instance table, adding the column.
columnnumber - the column number (you can put -1 to have the program itself has created room).
columnname - the name (header) column.

Example to add a text column number 0:

    ts_table(TableDescr1, "add_column",0,"string","material code + unit");

Example to add a numeric column with a calculated number by the value of variable n = i + 3

    ts_table(TableDescr1, "add_column",i+3,"double",szonename);


When you need to avoid duplication of records in a table you can use the convenient mechanism.
One of the speakers can be set as a so-called "primary key".
After that, all the lines that are added will be analyzed and if the table already has a row with the same value in the column, the new row will be created.
But if the append line is not a simple Directive "add_row" and "add_row_sum" the discovered line would sum the values of numeric columns (see add_row_sum).

Example to make the column number 1 as the primary key:


Example to do a column called "Object name" as the primary key:

  ts_table(TableDescr1,"set_first_key","Object name");  


Adds the row.

   ts_table(TableDescr1,"add_row", 0, objectname, 1, value_to_column_1, 2, value_to_column_2);

Here in column No. 0 store the value of the objectname variable, in column No. 1 of the recorded value value_to_column_1, and in column No. 2 of the recorded value of the variable value_to_column_2.

If the column No. 0 is set as "primary key" (specified in the directive set_first_key), we can write the values of columns a few commands:

   ts_table(TableDescr1,"add_row", 0, objectname, 1, value_to_column_1);
   ts_table(TableDescr1,"add_row", 0, objectname, 2, value_to_column_2);

The data will be appended to the same string value in the key column number 0.


Adding a row with sum in a numeric column with a string that matches the value of the key column.
The easiest way to explain to the actual beautiful example.
There are objects "Board." In these objects there is a field "size" ("100х40","50x40" etc.), "unit of measure" ("m","m2","m3") and "quantity".
We want to get the total table, where all objects of type "Board", the project was premirovalis as follows:

Material Unit Num
Board 100х50 м 1000
Board 50х40 м3 2000
Board 50х20 м2 1900

To do this, create a table with one key column and columns for the normal data

  ts_table(TableDescr1,"add_column",0,"string","object name + tiporazmer + edizm");
  ts_table("TableDescr, "set_first_key",0);
  ts_table(TableDescr1,"add_column", 1,"string",objectname); 
  ts_table(TableDescr1,"add_column", 2,"
  ts_table(TableDescr1,"add_column", 3,"
ts_table(TableDescr1,"add_column", 4,"double",kolvo);

To add a row into a table just use the following entry:

ts_table(TableDescr1,"add_row_sum",0,objectname+tiporazmer+edizm, 1,objectname, 2, tiporazmer, 3, edizm, 4, kolvo);

As a result, in a table, all objects with the same znacheniem name+size+unit. will be reduced to a single entry, and in the column "quantity" will be the sum of the quantities.


Sorting table rows by specified column or key column (if no arguments).

Example. Sorting tables by column number 0


Example. Sortirovka the table on the key column that you specified earlier.


After adding a new row requires re-sorting.


Quick search in a table of the first matching value column.
Returns the line number, or -1 if this string is missing in the table.

Example. Find the row with the value in column number 1 "Board"

    int irow = ts_table(TableDescr1,"search",1,"Board");


Make current the specified string in the table.

Example. To make the current first row in the table (the row index from 0 to n-1):

    int i=0;



Get the value from the specified column in the current row of the table

Example. Get the value from the column number 0 of the current row table to a variable objectname:

    string objectname;


To obtain the number of rows in a table in the specified variable

   int rowcount;
   ts_table(TableDescr1,"get_rows_count", rowcount);


To obtain the number of columns in a table in the specified variable

    int colcount;
    ts_table(TableDescr1,"get_columns_count", colcount);