|KiXtart 2001 Manual|
KiXtart supports two types of expressions: numeric and string. When working with expressions, KiXtart evaluates and resolves each part of the expression in a predetermined order. This predetermined order is known as operator precedence.
Numeric expressions can consist of any combination of:
KiXtart support the following numeric operators:
to sum two numbers.
to find the difference between two numbers or to indicate the negative
value of a numeric expression.
to multiply two numbers.
to divide two numbers and return an integer result.
& operator performs a bit-wise mathematical AND operation on two numbers.
| operator performs a bit-wise mathematical OR operation on two numbers.
To specify a number in hexadecimal notation, prepend it with an ampersand (‘&’).
A string expression can consist of any combination of the following:
A string expression can contain up to 32,000 characters. Any macros, or references to environment strings within a string (eg: “String with the macro @USERID in it.”) are resolved before the string is evaluated. For compatibility reasons, references to variables inside strings (eg: “String with a $Var in it.”) are also resolved before the string is displayed. The only exception to this rule are arrays, which can not be used inside strings. To use arrays or object references in combination with strings, you have to use concatenation.
Note: The characters @, %, or $ are normally used to indicate macros, environment strings, or variables. If you want to use these characters in a string, use @@, %%, or $$.
The following examples show the correct use of expressions in KiXtart:
$X = 1 + "20" ; $X type = integer / value = 21.
$X = &10 + &A ; $X type = integer / value = &1A (26).
$X = "1" + "20" ; $X type = string / value = '120'.
$X = @USERID + "1" ; $X type = string / value = 'USER1'.
"Current time = " + @time ; prints: "Current time = 12:34:00"
"Use @@time to print the time" ; prints: "Use @time to print the time "
$Y = "And this is how you access environment variables: %USERNAME%..."
IF @Day='Sunday' AND @USERID = 'RuudV'
$X = (@MONTHNO=3 AND @MDAYNO>=20) OR @MONTHNO=4
IF @WKSTA="VLEERBEER" OR @WKSTA="PALOMINE"
$X = ((@YDAYNO + 7) / 7) + 1
Old style use of variables inside a string:
"Use of a variable $Var inside a string."
New, preferred style to use variables in
combination with strings:
"Use of a variable " + $Var + " inside a string."
Strings in the script are displayed on the screen
in the current character size starting from the current cursor position. For
information about character size, see the BIG
and SMALL commands.
A string can be enclosed in single or double
quotation marks. To specify quotation marks in a string, either use the CHR
function or enclose the entire string in the opposite type of quotation marks
— .that is, if you want to
include single quotation marks in a string, enclose the string in double
quotation marks, and vice versa.
The following examples show the correct use of string expressions in KiXtart:
"Hi "+ @userid
'Double quote in a string: (")'
Double quote in a string: (")
"Single quote in a string: (')"
quote in a string: (')
"More double quote: " + Chr(34)
More double quote: "
KiXtart determines the type of the expression
from the first element of the expression.
Both string and numeric expressions can contain the following conditional and logical operators:
|=||Equal (case insensitive)|
|==||Equal (case sensitive)|
|<=||Less than or equal|
|>=||Greater than or equal|
When several operations occur in an expression, KiXtart evaluates and resolves each part of the expression in a predetermined order. This predetermined order is known as operator precedence.
Parentheses can be used to override the order of precedence and force some parts of an expression to be evaluated before other parts. Operations within parentheses are always performed before those outside the parentheses. Within parentheses standard operator precedence is maintained.
The precedence of operators affects the grouping and evaluation of operands in expressions. Expressions with higher-precedence operators are evaluated first.
The following table summarizes the precedence of the supported operators, listing them in order of precedence from highest to lowest. Where several operators appear together, they have equal precedence and are evaluated from left to right.
|Operator||Type of operation|
|[ ] ( )||Expression|
|+ - Not||Unary|
|< > <= >=||Relational|
|And Or||Logical AND, Logical OR|