Mathematical operators perform classic calculation operations:
|+||Binary||Addiction (or unary positive)|
|-||Binary||Subtraction (or unary negative)|
|%||Binary||Modulus (returns the remainder of a division)|
|()||Binary||Grouping operations (establishes wich operator, or groups of, has the precedence)|
Strings operators manipulate character strings (or other character data types), performing concatenation operations:
|+||Binary||Concatenates two strings, leaving character spaces in place.|
|-||Binary||Concatenates two strings, removing interposed spaces..|
Also known as boolean values, logical operators performs test of truth on groups or single expressions.
Operators are classified according to whether they act on a single term or on an expression:
Unary - acts on a single expression:
Binary- requires two terms or expressions:
2 + 2
winter .AND. cold
|.and.||Binary||Returns TRUE (.t.) if both terms are true|
|.or.||Binary||Returns TRUE (.t.) if either terms are true (first take precedence on second)|
|.not.||Unary||Returns TRUE (.t.) if the term is false|
|!||Unary||(alternative sintax) returns TRUE (.t.) if the term is false|
|()||establishes precedence on evaluation|
Evaluation take places in this order:
.NOT. or .NOT.
.AND. or .AND.
.OR. or .OR.
Parentheses influences the order of evaluation. Grouping values into parenthes force a preventive evaluation and affects order of evaluation.
//-- testing end-of-file condition
if .not. eof()
//-- testing numeric condition
if (nBalance = 0 .and. lCreditLine)
//-- testing multiple conditions
// and setting an error flag
lErr := .f.
if .not. empty(cKey) .and. .not. found()
lErr := .t.
MaxScript offers a special operator for handling data inside web pages: it permits to force any data type to string and concatenate them.
Web page can only host pure text, and thus any kind of output that program logic produces must be reduced into strings. The universal concatenator generates a string starting from multiples values:
||||Binary||Placed between two elements converts them to string and then concatenates the results into a single string.|
//-- building a string that says today's date and 22 days left
cStr := Today is //-- string
dToday := date() //-- date
nDays := 22 //-- number
? cStr | dToday | and there are | nDays | days left!
There is class of elements of MaxScript language that stands between commands and operators: the pseudo-directives.
Pseudo-directives are classified as commands but are not used to manipulate data or variables, but to instruct the interpreter to use some specific setting from that point onward. A pseudo-directive remains in place until another one take action or until the end-of-page is reached.
Usually they starts withSET as in SET DATE TO BRITISH.
This is a list of most common ones you will encounter:
There are also other SET commands (see further for a complete description).