The xBase expressions consist of following components:
Constants. There exist numeric constants (1,
2, 0, -5, 7.3 etc.),
character constants (symbol strings enclosed in quotes:
"Hello!", 'H', " " etc.) and
logical constants (only two of them: .T. and
.F.).
[NOTE. Single or double quotes usually have no effect on the evaluation of xBase expression. In Star4Win, however, there is an important distinction: if you edit a database file with variable length fields, specifying an expression with single quotes while LOCATing will result in a quicker (but less accurate) search. Use single quotes in Locate expressions (e.g.: 'something' $ somefield) if you want the search to be conducted quicker, but be aware that some information may never be found (especially if you use complex function syntax in your request). Use double quotes (e.g.: "something" $ somefield if you do not want to miss anything.]
Memory variables. These are denoted as character strings without quotes,
e.g. A, b, GREETING,
chaR etc. (the letter case has no relevance for memory
variables: GREETING is the same as GReEtIng). Only
standard Roman characters and the _ sign can be used in memory variable
names.
Function names. A function is noted like a memory
variable (without quotes), but must include round brackets:
Time(), Chr(221), Sqrt(343),
SubStr(Trim("Hello! ", 2, 4)) etc. A function is in fact a
symbolic conversion of a standard procedure (which may be very long in a
real programming language). The expression in brackets itself may be any
valid dBASE expression and is called the function argument.
A function must return a value for its argument, and this value itself
becomes a constant, e.g. Sqrt(4) = 2 (Sqrt() returns
the square root). A function may also have several arguments (in which
case they are separated by commas within the round brackets) or none -
e.g. the function Time() which returns the current time without
any arguments specified.
Operators. There exist several kinds of operator signs:
+ (addition),
- (subtraction), / (division), *
(multiplication), ** or ^ (power), %
(modulus operator returning the division remainder). E.g.:
2+3 = 5, 7-6 = 1, 6/3 = 2,
3*3 = 9, 2**3 = 8, 20%3 = 2 etc. You
can also use round brackets in their standard mathematical meaning
(indicating the priority of operation): (2+3)*5 = 25. Note that
the expression 2+3*5 without brackets is equivalent to
2+(3*5) (which equals to 17).
+ can be used also
with character strings, adding one string to another:
"Hello, "+"world!" = "Hello, world!".= (equal to),
> (greater than), < (less than),
>= (greater or equal), <= (less or equal),
!= (not equal to, also can be specified as
<>). E.g. a <= b, 4>3 etc.
"ABC" is considered "less" than
"ABD" (since C precedes D). Note also, that the alphabet is ordered not
quite in a standard way: uppercase letters precede the lowercase (thus
while "ABD" is "more" than "ABC", it is "less"
than "abc" or even "aBC").
All other signs (commas, dots, spaces etc.) are also ordered according
to the standard ASCII character order..and., .or., and
.not. (dots are obligatory!). The operator .not.
can be combined with the other two, forming new complex operators
.and..not. and .or..not.. For example:
a = b .and. b = d (meaning: a is equal to b while b is equal to d);
x > 3 .or. x < -2 (meaning: x more than 3 or
x less than -2 - the interval between -2 and +3 is excluded from the possible
values of x);
x > 4 .and..not. x < 7 (meaning: x more than
4, but not less than 7) which is in fact equivalent to an expression:
x >= 7 etc.$ which evaluates whether a certain string
is a substring of another string or not. For example:
'stop' $ 'bus-stop' = .T.
('stop' is contained within the string 'bus-stop').
'st ' $ 'bus-stop' = .F. (the combination
'st' within 'bus-stop' is followed by
'o', not by a space) etc.
"o" $ grm - it will move the cursor to the first record where the GRM
(German) word contains the letter o (pressing F4 will move you to the next
record satisfying this condition etc.). Note that if you will ask to locate
for: grm="o", this will move the cursor to the first record where the German
word begins with o.,), which is
used in two cases: first, as a separator of parameters in function brackets
(see below); second, as a normal comma when you list field names in a file
(e.g.: NUMBER, WORD, RUS, POL etc.).
See also: ?, STANDARD FUNCTIONS, STARLING FUNCTIONS.