KiXtart supports three types of expressions: string, integer and double.
A string expression can consist of any combination of the following:
· Literals (a sequence of characters enclosed in quotation marks)
· Functions that return a string
· Object references
· Plus signs (+), which indicate concatenated sub-expressions
Integer and double expressions can consist of any combination of:
· Sub-expressions
· Numeric values (in decimal, hexadecimal or floating point notation, see below for details)
· Functions that return a numeric value
· Object references
· Numeric operators (+, – , *, /, mod, &, |)
Decimal notation:
[-|+]<digits>
Hexadecimal notation:
[-|+]<&digits>
Floating point notation:
[-|+]<digits.>[digits][e<exponent>]
KiXtart support the following numeric operators:
+ |
Used to sum two numbers. |
- |
Used to find the difference between two numbers or
to indicate the negative value of a numeric expression. |
* |
Used to multiply two numbers. |
/ |
Used to divide two numbers and return an integer
result. |
mod |
Used to divide two numbers and return only the remainder. |
& |
Performs a bitwise mathematical AND operation on two
numbers. |
| |
Performs a bitwise mathematical OR operation on two
numbers. |
^ |
Performs a bitwise mathematical XOR operation on two
numbers. |
~ |
Performs a bitwise mathematical negation operation
on a number. |
To specify a number in hexadecimal notation, prepend it with an ampersand (‘&’).
Both string and numeric expressions can contain the following conditional and logical operators:
· < less than
· > greater than
· = equal (case insensitive)
· <> not equal
· <= less than or equal
· >= greater than or equal
· == equal (case sensitive)
· Not
· And
· Or
A string expression can contain up to 32,000 characters. Any macros, or references to environment strings within a string (e.g.: "String with the macro @USERID in it.") are resolved before the string is evaluated.
By default, references to variables inside strings (e.g.: "String with a $Var in it.") are also resolved before the string is displayed. The only exceptions to this rule are arrays and object references, which can not be used inside strings. To use arrays or object references in combination with strings, you have to use concatenation. Note that you can disable resolving of variables or macros inside strings by using the NoVarsInStrings or NoMacrosInStrings options (see SetOption for full details).
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:
Code |
Output |
"Hi
"+ @userid |
Hi
Ruudv |
'Double quote
in a string: (")’ |
Double
quote in a string: (") |
"Single
quote in a string: (')" |
Single
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.