How can I do extended maths calculations such as cosine, log and exponential in SilkTest?
Maths functions are currently not available within the 4Test proprietary language. There are many ways to perform this task, two of which are to use either Java (using the Silk4J eclipse plugin) and the math library within the Java language, or we can also use the math library available in the C/C++ language. The C/C++ language is advantageous as it allows us to create a dll which contains the math functions required, which in turn, we can call from SilkTest by calling the functions available in the dll file. This is available in the downloadable attachment Math.zip.
This archive contains the following files:
These files provide the cmath library functions to enable math functions to be used in SilkTest.
The functions available in the dll file are the functions available in the cmath library .
cmath declares a set of functions to compute common mathematical operations and transformations
1. Extract the Math folder in the archive to the SilkTest installation directory
The following functions are available in Math.inc
_cos (double num)
_sin (double num)
_tan (double num)
_acos (double num)
_asin (double num)
_atan (double num)
_atan2 (double y, double x)
_cosh (double num)
_sinh (double num)
_tanh (double num)
EXPONENTIAL AND LOGARITHMIC FUNCTIONS
_exp (double num)
_frexp (double num)
_ldexp (double num, int exp)
_In (double num)
_log10 (double num)
_log (double num, double base)
_modf (double num)
_pow (double base, double exp)
_sqrt (double num)
ROUNDING, ABSOLUTE VALUE AND REMAINDER FUNCTIONS
_ceil (double num)
_fabs (double num)
_floor (double num)
_fmod (double numerator, double denominator)
REAL Round (REAL rOriginal, INTEGER iPlaces optional)
Once the Math folder has been extracted to the SilkTest installation directory,
user can specify the Math.inc file in the SilkTest Runtime Options or within the Testscript file.
Specifying Math.inc in the SilkTest Runtime Options for usage across SilkTest project:
1. From SilkTest, goto Options | Runtime
2. In the "Use files" section, add "Math\Math.inc"
Specifying Math.inc in SilkTest Testscript file for usage in a single Testscript file:
1. Add the following line at the beginning of the Testscript file