Creates a custom function object with one variable and up to 15 constant arguments.
'x' represents the variable, 'a' through 'n' the constants.
The constant 'e' is predefined as 2.718281828459045235360287, the constant 'pi' is predefined as 3.141592653589793238462643. Thus as an example, you can input the string 'x^2-a+(d*c*x)-b' (not including the single quotes) for the 'Formula' parameter.
This string has x as the variable (which is true in all cases) and has defined 4 constant parameters (a, b, c and d).
The value of these 4 constant parameters must be provided via the 'Const_a', 'Const_b', 'Const_c' and 'Const_d' parameters.
If for example, values of 2, 5, 1.2 and 2 are used respectively, you have essentially defined the function 'x^2-a+(d*c*x)-b' => 'x^2-2+(2*1.2*x)-5' => 'x^2+2.4*x-7'. You may use the regular c++ math functions (min, max, exp, log, sqrt, sin, cos, log10).
We have also implemented an if(condition, true, false) function which can be used in the following manner.
'if(a>=c,5,a+b)*5.2'. This object can be pass to the integration functions (contained within this category of functions) in order to integrate the expression between limits.
You can also evaluate the expression via the
EvaluateFunction() function at a particular point.
Internally the string-function is converted into bytecode so that repeated execution of the expression avoids the parsing and validation phase.
This function creates an object and returns a string-key value to represent this created object.
The TAG value of the string-key returned (second part of the key) is : "CUSTFUNC"
- Key parameter
Key value to use as a handle for the created object
- Reload parameter
When creating this object for the first time, set this parameter to a positive value. Within Excel, when re-computing a worksheet where you do not wish to recreate the object, set this parameter to zero (0).
- Formula parameter
Formula of interest [ie - min(max(x-a,b),max(d-a,e))+exp(c)-log(-g*h)+if(d>=f,5,6) ] (Do not include quotes around the formula).
- Const_a parameter
Constant numeric value for this parameter.
- Const_b parameter
Constant numeric value for this parameter.
- Const_c parameter
Constant numeric value for this parameter.
- Const_d parameter
Constant numeric value for this parameter.
- Const_f parameter
Constant numeric value for this parameter.
- Const_g parameter
Constant numeric value for this parameter.
- Const_h parameter
Constant numeric value for this parameter.
- Const_i parameter
Constant numeric value for this parameter.
- Const_j parameter
Constant numeric value for this parameter.
- Const_k parameter
Constant numeric value for this parameter.
- Const_l parameter
Constant numeric value for this parameter.
- Const_m parameter
Constant numeric value for this parameter.
- Const_n parameter
Constant numeric value for this parameter.
The C# example below contains all the sub-function calls leading up to this function call. As a result, the example can contain a lot of code.
The VB.NET, J#, C++.NET, Java, Excel VBA, Visual Basic 6 (via COM) and C++ examples below contain function code stubs for the calls leading up to this function call. However, the function call for this function is displayed.
You can easily reproduce the stub functions code from the
C# example.
Copyright (c) 2003-2007 CapeTools - All Rights Reserved.