MaxScript Operators
 

Mathematical Operators

Mathematical operators perform classic calculation operations:

Operator

Type Action
+ Binary Addiction (or unary positive)
- Binary Subtraction (or unary negative)
* Binary Multiplication
/ Binary Division
% Binary Modulus (returns the remainder of a division)
^ Binary Exponentiations
** Binary Exponentiations
() Binary Grouping operations (establishes wich operator, or groups of, has the precedence)

String operators

Strings operators manipulate character strings (or other character data types), performing concatenation operations:

Operator Type Actions
+ Binary Concatenates two strings, leaving character spaces in place.
- Binary Concatenates two strings, removing interposed spaces..

Logical operators

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:

.NOT. paid

• Binary- requires two terms or expressions:

2 + 2

winter .AND. cold


 

Operator

Type Action
.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.

Examples:

//-- testing end-of-file condition

if .not. eof()

   go bottom

endif


 

//-- testing numeric condition

if (nBalance = 0 .and. lCreditLine)

*--

endif


 

//-- testing multiple conditions

// and setting an error flag

lErr := .f.

seek cKey

if .not. empty(cKey) .and. .not. found()

   lErr := .t.

endif

Universal concatenator

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:

Operator

Type Action
| Binary Placed between two elements converts them to string and then concatenates the results into a single string.

Example:

//-- 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!”


 

Pseudo Directives

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 with”SET” as in SET DATE TO BRITISH.


 

This is a list of most common ones you will encounter:

SET DATE

SET DECIMALS

SET DELETED

SET CENTURY

SET ALTERNATE

There are also other SET commands (see further for a complete description).