Previous Topic

Next Topic

Book Contents

Book Index

MaxBasic Expressions

An expression is a combination of constants, variables and operators that yield new values. When a script runs, you can evaluate an expression, and inspect and save the value, by assigning it to a variable. MaxBasic expressions are composed of operands (variables, object properties or sub-expressions) and operators. The value of an expression can be a number, a string, a Boolean value (True or False) or Null (not valid).

Constant Strings in Expressions

Strings in expressions must be in double Quotes. The following is a valid string constant: "Accredo Business Software".

Constant Dates in Expressions

A date constant is a valid date enclosed in the # character. The date will be interpreted in terms of the Windows date format (for example, for ordering of day and month). The following is a valid date constant: #31/10/2025#.

MaxBasic Expression Examples

In the examples it is assumed a Customer object called Customer exists.

Expression

Description

1

Numeric constant, returns 1

1.5

Numeric constant, returns 1.5

"Accredo"

String constant, returns "Accredo" as a string

True

Logical constant, returns True

1 + 2

Numeric calculation, returns 3

2 * (3 + 2.5)

Numeric calculation, returns 11

"Accredo" & " is great"

String calculation, returns "Accredo is great"

Customer.CustomerName

Returns the value of the CustomerName property in the Customer object

Customer.CustomerName & " " & Customer.ContactName

Concatenates the CustomerName, a blank and the ContactName

Balance3 + Balance2

Numeric calculation – adds the value of Balance3 and Balance2 variables

"Printed " & Date

String calculation

"Amount paid is " & Customer.AmountOfLastReceipt

String calculation. Converts the Amount of Last Receipt for a Customer into a string and concatenates to the string "Amount paid is "

IIF(Customer.SalesYearToDate > 10000, "Priority Customer", "Customer")

Returns "Priority Customer" if the Customers Sales Year To Date is greater than 10000, or returns "Customer"