"updateLines"

Finds columns using key values and replaces certain values in multiple lines.

Synopsis

1)

setValue (string shape, "updateLines", int n, string keyName1, <dyn_type1> keyValue1 [, string keyName2, <dyn_type2> keyValue2 ...] string reName1, <dyn_type1> reValue1 [, string reName2, <dyn_type2> reValue2 ...][,int formatType[, dyn_int rowFontType][, dyn_string backColor][, dyn_string foreColor]]);

shape.updateLines (int n, string keyName1, <dyn_type1> keyValue1 [, string keyName2, <dyn_type2> keyValue2 ...] string reName1, <dyn_type1> reValue1 [, string reName2, <dyn_type2> reValue2 ...][,int formatType[, dyn_int rowFontType][, dyn_string backColor][, dyn_string foreColor]]);

2)

setValue ( string shape, "updateLines", int n, string keyName1, <dyn_dyn_type1> keyValue1 [, string keyName2, <dyn_dyn_type2> keyValue2 ...] string reName1, <dyn_dyn_type1> reValue1 [, string reName2, <dyn_dyn_type2> reValue2 ...][,int formatType[, dyn_int rowFontType][, dyn_string backColor][, dyn_string foreColor]]);

shape.updateLines (int n, string keyName1, <dyn_dyn_type1> keyValue1 [, string keyName2, <dyn_dyn_type2> keyValue2 ...] string reName1, <dyn_dyn_type1> reValue1 [, string reName2, <dyn_dyn_type2> reValue2 ...][,int formatType[, dyn_int rowFontType][, dyn_string backColor][, dyn_string foreColor]]);

Parameters

Parameter Description
shape Name of the object
n Number of keys
keyName1 Name of the key column
keyValue1 Key value (dyn_type/dyn_dyn_type any)
reName1 Name of column to be replaced
reValue1 New value (dyn_type/dyn_dyn_type any)
formatType

The parameter formatType can be a combination (binary) of the following flags:

TABLE_FONTTYPE, TABLE_BACKCOLOR and TABLE_FORECOLOR.

Enter the further parameters accordingly:

dyn_int rowFontType][, dyn_string backColor][, dyn_string foreColor]]

The constants can be used together by using the '|' operator.

rowFontType

The font type. There are four different font types available:

0 = Normal (default)

1 = Bold

2 = Italic

3 = Italic bold

dyn_string backColor

dyn_string foreColo

The background color for a table

The foreground color for a table

Description

This attribute is used to replace or insert values in certain columns of multiple lines indexed by key values (analogous to "updateLine"). If there is no line matching the keys in "keyValue" in the respective columns ("keyName"), a new line is added to the table based on the specified parameters. If optional color information is indicated in the key values (see the example further on), it is not used as a search criterion but rather the color values of the key values are replaced by the new information. In principle, the function works similar to "updateLine", the main difference being that "updateLines" passes arrays of key values and "new" values instead of individual variables. In this way, it is possible to replace several lines at the same time. The parameter "rowFontType" enables the definition of a font type for a specific row.

Please note that the function will only update the first line that matches the stated keyName. This means, that if multiple lines use the same keyName only one is updated. To update multiple lines with the same keyName you must create your own Control code within your scripts.

Example

This example finds all lines containing "Peter" and "Paul" in the "Name" column in "table123". If they exist, the values from the array ds2 (can also contain color information) are inserted into the column "Salary". However, if no values are found, the lines are created new and appended to the end of the table.

By passing the color information in the array ds1[2], the color of the key cell "Paul" will be changed in the column "Name".

main()
{
  shape table = getShape("table123");
  dyn_dyn_string ds1, ds2;

//Key values
  ds1[1] = makeDynString("Peter");
  ds1[2] = makeDynString("Paul", "[50, 30, 0]", "[15, 0, 30]");

//New values
  ds2[1] = makeDynString("12000");
  ds2[2] = makeDynString("20000", "[100, 40, 40]", "Red");

//Replace, insert values
  table.updateLines(1, "Name", ds1, "Gehalt", ds2);
}

In following example a query is performed and the results are added to a table. The font as well as the fore- and background color of the table are set.

main()
{
  dyn_dyn_anytype tab;
  int z;
  dpQuery("SELECT '_original.._value' FROM 'ExampleDP_Arg*' WHERE _DPT=\"ExampleDP_Float\" ", tab);

//DP query
  DebugN("Query executed:", tab);

//_DTP returns the data point type
  dynRemove(tab, 1);
//Remove query header
  dynDynTurn(tab);
/* Rows are set to columns and vice versa, see dynDynTurn()*/
  DebugN("dynDynTurn executed:");
  int formatType = TABLE_FONTTYPE|TABLE_FORECOLOR|TABLE_BACKCOLOR;
/* Specify constants*/
  dyn_int rowType = makeDynInt(1);
//Font typ = Bold
  dyn_string foreColor = makeDynString("BA_Aussenluft");
  dyn_string backColor = makeDynString("_ETM");
/* Specify the colors for the table*/
  setValue("ValueTable","updateLines", 1, "dpe", tab[1], "value", tab[2],formatType,rowType,foreColor, backColor);
}

Assignment

Table