Script functions reference > Script functions in alphabetical order > A > AddSubst

AddSubst
Syntax
AddSubst(tbl_file, str_key, num_col, str_value);
tbl_file 
str_key 
num_col 
str_value 
A string representing a numeric value to add to the value found in column num_col. The number may be given with or without a decimal point. The function rounds the value to the maximum number of decimals given previously or in this parameter. You can use a negative number to subtract.
Description
Adds str_value to the value in num_col of the specified substitution table entry. It does not affect the physical file stored on disk, only the representation of the table in the memory. The substitution table file is specified by tbl_file, and the substitution table entry is specified by str_key. If the key or column does not exist, it will be added.
Returns
Returns the sum of the old value retrieved from the substitution table, and the value given in str_value.
Example
In this examples, the following substitution table (author.tbl) is used.
//!CodePage UTF8!
//!multicolumn!
agatha christie  1890
alfred hitchcock 1899
Example 50
In the following script, the variable $century gets the value 1899 + 100.
$century = AddSubst("../data/tables/author.tbl","alfred",1,"100");
 
Example 51
The following script adds the substitution table entry astrid:
SetSubst("../data/tables/author.tbl","astrid",0,"lindgren");
AddSubst("../data/tables/author.tbl","astrid",1,"1907");
WriteSubst("../data/tables/author.tbl");
After the script is executed, author.tbl is changed as follows:
//!CodePage UTF8!
//!multicolumn!
agatha christie    1890
alfred hitchcock   1899
astrid lindgren    1907
 
Notes
OpenText StreamServe 5.6 Updated: 2013-03-01