Using functions in expressions, Working with the mapbasic window – Pitney Bowes MapInfo Professional User Manual

Page 446

Advertising
background image

And

Or

Lowest Priority:

For example, the expression 3+4*2 produces a result of 11. That is because multiplication has a higher
precedence than addition and is performed first, in effect:

3+4*2=
3+8=
11

We can add parenthesis to force MapInfo Professional to do the addition first:

(3+4)*2=
7*2=
14

Now consider expression 60, which is intended to select all records July or September of 1989.

1. year(RECEIVED)=89 and month(RECEIVED)=7 or month(RECEIVED)=9

Because "and" has higher precedence than "or", MapInfo Professional treats this expression as though
"year(RECEIVED)=89 and month(RECEIVED)=7" was enclosed in parentheses.

1. (year(RECEIVED)=89 and month(RECEIVED)=7) or month(RECEIVED)=9

In this case, any record for July of 89 or for September of any year would be selected. That is probably
not what you want. However, by adding parentheses to the second expression, you can get this:

1. year(RECEIVED)=89 and (month(RECEIVED)=7 or month(RECEIVED)=9)

In this expression, the parentheses tell MapInfo Professional that "month(RECEIVED)=7" and
"month(RECEIVED)=9" are alternatives in the second clause of the expression. MapInfo Professional
treats this the same as it treats number 53 above.

When you are not sure how MapInfo Professional evaluates an expression with several operators,
you should use parentheses to group elements as you want them.

Note:

Using Functions in Expressions

Functions take data values and perform some operation on them to produce a new value. Functions
have the following form:

SomeFunction(parameters)

Most of MapInfo Professional's functions take one or two parameters. A parameter can be a column or
another expression. MapInfo Professional uses the keyword "obj" or "object" with the geographic functions:
Area, CentroidX, CentroidY, ObjectLen, and Perimeter. This keyword tells MapInfo Professional that it
has to get values based on graphical objects in the table rather than tabular data.

• For more information about specific functions, see the Help System.

Working with the MapBasic Window

This section allows advanced MapInfo Professional users to go behind the scenes and take advantage
of functions that enhance the use of MapInfo Professional through the MapBasic window. MapBasic is
MapInfo Professional's programming language that allows you to customize and automate MapInfo
Professional functionality. When MapBasic was created, the MapBasic Window feature was added to
MapInfo Professional as a means of testing and debugging code for an application. It became apparent

MapInfo Professional 12.5

446

Working with the MapBasic Window

Advertising