Purpose
Returns information about the current selection. You can call this function from the MapBasic window in MapInfo Pro.
Note: Selected labels do not count as a "selection," because labels are not complete objects, they are attributes of other objects.
Syntax
SelectionInfo( attribute )
attribute is an integer code from the table below.
Return Value
String or integer; see table below.
Description
The table below summarizes the codes (from MAPBASIC.DEF) that you can use as the attribute parameter.
attribute setting | ID | SelectionInfo() Return Value |
---|---|---|
SEL_INFO_TABLENAME | 1 | String: The name of the table the selection was based on. Returns an empty string if no data currently selected. |
SEL_INFO_SELNAME | 2 | String: The name of the temporary table (for example, "Query1") representing the query. Returns an empty string if no data currently selected. |
SEL_INFO_NROWS | 3 | Integer: The number of selected rows. Returns zero if no data currently selected. |
SEL_INFO_ISNEW | 4 | Logical: returns T (true) if the current selection set is new. |
Note: If the current selection is the result of a join of two or more tables, SelectionInfo(SEL_INFO_NROWS) returns the number of rows selected in the base table, which might not equal the number of rows in the Selection table. See example below.
Error Conditions
ERR_FCN_ARG_RANGE (644) error is generated if an argument is outside of the valid range.
Example
The following example uses a Select statement to perform a join. Afterwards, the variable i contains 40 (the number of rows currently selected in the base table, States) and the variable j contains 125 (the number of rows in the query results table).
Dim i, j As Integer
Select * From States, City_125
Where States.obj Contains City_125.obj Into QResults
i = SelectionInfo(SEL_INFO_NROWS)
j = TableInfo(QResults, TAB_INFO_NROWS)
See Also:
Select statement, TableInfo() function