Cond() function - MapBasic - 2023

MapInfo MapBasic Reference

Product type
Software
Portfolio
Locate
Product family
MapInfo
Product
MapInfo > MapBasic
Version
2023
Language
English
Product name
MapBasic
Title
MapInfo MapBasic Reference
First publish date
1985
Last updated
2023-09-12
Published on
2023-09-12T16:32:32.686312

Purpose

This function is equivalent to a programmatic case statement: it compares an expression against each search value in order. You can call this function from the MapBasic window in MapInfo Pro.

Syntax

Cond( expression, search, result 
[, search, result ] ... [, Default ] )

expression The expression you want to evaluate.

search The value that the expression will be compared to.

result The result for the search value.

Return Value

If the expression and search argument are the same, then a result value is returned.

If there is no match found for an expression and Default is not present, then this function returns an error.

Description

This function can take multiple search cases with corresponding values. The expression, search, and result values are all required.

Default is optional. It is returned when no match is found. If Default is not specified and there is no match, then an error is returned.

Example

Cond (hire_date, sysdate,"NEW JOINEE","EMPLOYEE")
Select State_Name "State", cond(Pop_Density, Pop_Density < 10, "Low Density", Pop_Density >= 10 AND Pop_Density < 100, "Medium Density", "High Density") "Population Density" from states
shade 1 with str$(Cond(Pop_Density, Pop_Density < 10, "Low Density",Pop_Density > 10 And Pop_Density < 100, "Medium Density", "High Density")) values "Low Density" brush(255,255,2), "Medium Density" brush(255,16711680,2), "High Density" brush(255,65280,2)

See Also:

IIf() function