Scripts
Models can be defined using scripts. Use the
Edit/Script editor option, to make the script developing environment
visible. Scripts can be written using VBscript or JScript, which are the MS
Windows implementation of the Visual basic and Java scripts. Support for other
script languages can be also installed - Python, Perl etc.
By default all scripts are VBscript. The name of the script language is
specified on the first line of the script,
'script language = VBscript
The first function of in the script must be called 'MAIN'. There could be
more than one functions, but during optimization and contour surface plots, the
one called 'MAIN' will be executed.
The script uses standard Visual Basic commands. Read more about this here:
http://msdn2.microsoft.com/en-us/library/t0aew7h6.aspx
To communicate results to and from QstatLab - use the QS object. Here are the
properties and methods of this object:
- qs_NVARS - number of variables during optimization and surface plots
- qs_VAR(i) - the value of the i-th input variable
- qs_RESULT(j) - the value of the j-th output variable
- qs_sqr(number) - the value of number * number
- qs_sqrt(number) - square root of number
- qs_power(p,e) - the value of p^e (p to the power e)
- qs_ln(p) - the natural logarithm
- qs_log2(p) - the log base 2 of P
- qs_log10(p) - the log base 10 of P
- qs_logN(p) - the log base N of P
- qs_exp(p) - Exponential of P. Returns the value of 'e' raised to
the power of P, where 'e' is the base of the natural logarithms
- qs_abs(p) - returns the absolute value of the argment
- qs_floor(p) - the highest integer less than or equal to p. floor(-2.8) =
-3; floor(2.8) = 2; floor(-1.0) = -1
- qs_ceil(p) - the lowest integer greater than or equal to p. ceil(-2.8) =
-2; ceil(2.8) = 3; ceil(-1.0) = -1
- qs_trunc(p) - the integer part of the argument p. Trunc(123.456) = 123
- qs_frac(p) - the fractional part of the argument p. Frac(123.456) =
0.456
- qs_frexp(x,mantissa,exponent) - separates the mantissa and exponent of
X.
- qs_min(a,b) - returns the smaller value of the two
- qs_max(a,b) - returns the larger value of the two
- qs_pi - returns 3.1415926535897932385
- qs_cls - clears the screen
- qs_print(p) - prints the value of p to the screen below the script
editor
- qs_CELLSTR(col,row) - the value of a cell from the spreadsheet -
qs_CELLSTR(1,0) will return 'A'; qs_CELLSTR(1,1) will return 'Name1'
- qs_CELLFORMULA(col,row) - a string containing the formula in the cell,
instead of the result.
- qs_CELLCALCULATE - makes the spreadsheet recalculate all cells
- qs_SPREADFUNC(SpreadFuncion) - returns the value of SpreadFunction. For
instance: qs_SPREADFUNC("=A1+A2") will return the sum of cells A1 and A2;
qs_SPREADFUNC("=AVERAGE(A1:A10)") will return the average of A1 to A10.
See also
Back to Data Entry