[contents]
Contents
Syntax
The syntax for exprtk.add_variable calls is:
f++:
exprtk.add_variable(params)
n++:
@exprtk.add_variable(params)
Description
The exprtk.add_variable function is for adding variables to the ExprTk symbol table, it takes a non-zero number of variables which should each be one of the following types:
- bool
- int
- double
- std::double
- char
- string
- std::vector<double>
Note: With the exception of std::double, variables of the above types are all added to the ExprTk symbol table for you when defined, however if you overload a variable name in a different scope you will need to manually re-add variables you want to use in ExprTk expressions once that scope has been destroyed.
f++ example
Example of exprtk.add_variable being used with f++:
int i=12
for(int i=0; i<10; i+=1){}
exprtk.add_variable(i)
exprtk{!o}(println(i))
Note: If you do not manually re-add the original i back the the ExprTk symbol table then the output of the above example will be 10.00000 rather than the desired 12.00000.
n++ example
Example of exprtk.add_package being used with n++:
@int(i=12)
@for(int i=0; i<10; i+=1){}
@exprtk.add_variable(i)
@exprtk{!o}(println(i))
Note: If you do not manually re-add the original i back the the ExprTk symbol table then the output of the above example will be 10.00000 rather than the desired 12.00000.