Purpose
Modifies an existing Browser window. You can issue this statement from the MapBasic window in MapInfo Pro.
Syntax
Set Browse
[ Window window_id ]
[ Grid { On | Off } ]
[ Row row_num ]
[ Column column_num ]
[ Columns Resize ]
[ Order By sortColumn [ Desc ] [ , sortColumn2 ... ] ]
[ Order None ]
[ Filter Where
(filterCondition [ And | Or filterCondition ] )
[ And (filterCondition [ And | Or filterCondition ] ) ... ] ]
[ Filter None ]
[ SortFilter { On | Off } ]
[ Reapply ]
window_id is the integer window identifier of a Browser window or a Redistricter window.
row_num is a SmallInt value, one or larger; one represents the first row in the table.
column_num is a SmallInt value, zero or larger; zero represent the table's first column.
sortColumn identifies the column(s) to use for sorting the browser, using syntax similar to SQL Select.
Desc is optional and specifies a descending-order sort. Up to four columns can be used for sorting: for example:
Set Browse Order By Country, City, Income Desc
filterCondition is a simple logical condition (such as Population > 12345) to limit which rows display in the Browser window. The expression can include only simple column names, operators, and constants (such as 12345.67 for numeric constants and text in quotes like "Kerry" for string constants). Function calls are not supported, but the Like operator can be used to perform wildcard matching when filtering a character column. Up to two conditions (enclosed within parentheses) can be applied per column.
Description
The Set Browse statement controls the settings of an existing Browser window. If no window_id is specified, the statement affects the topmost Browser window.
The optional Window clause lets you specify which document window to use. If a window_id is not specified, then it searches for the most recently used Browser window or Redistricter window. If neither Redistricter nor Browser is the front-most window, but both exist, then Set Browse finds the Browser window instead of the Redistricter window. To specify which window type to use, either include the window_id with the Set Browse statement or make the Redistricter window the front-most window before calling Set Browse.
The optional Grid clause displays (turns on) or does not display (turns off) the grid lines in a Browser window.
The optional Row and Column clauses let you specify which row should be the topmost row in the Browser, and which column should be the leftmost column in the Browser.
The optional Columns clause lets you set column resizing based on the width of the column header (title) and the contents that are in view. On first display, the Browser window automatically resizes columns to completely contain the data that is visible. When scrolling vertically, the Browser window does not automatically adjust the column width for the new data in view. You must set the Columns clause to make this happen. After recalculating column width, the width does not change while scrolling―columns do not resize to the new data in view. If the user manually resizes a column, then its width does not change.
Order By If you have used the Pick Fields dialog to customize the name of the column, the Set Browse statement must match the new custom column name. If the custom column name includes spaces ("Customer Name"), then the Set Browse statement must use a column number, such as Order By Col2 or Order By 2.
The Filter Where clause applies filter conditions to limit which rows appear in the window. The syntax after the Where keyword is similar to a SQL Select Where clause, but simpler. Each column can have no more than two conditions, and conditions cannot use function calls or complex expressions. To perform wildcard matching on character columns, use the Like operator; for example:
Set Browse Window FrontWindow() Filter Where (age > 50 And age <= 70)
Set Browse Window FrontWindow() Filter Where
(continent Like "%America") And (startdate > "19991231")
Once you have applied filter and/or sort conditions, you can toggle them on or off using the SortFilter clause:
Set Browse Window FrontWindow() SortFilter Off
If sort/ and/or filter conditions are applied, and then the user edits the table, the conditions are not refreshed immediately. To force a refresh, use the Reapply keyword:
Set Browse Window FrontWindow() Reapply
To clear all filter conditions from the Browse, specify Filter None.
Filter conditions are associated with the Browser window, not the table. To save filter conditions, save a workspace file. To generate a query table that contains the same rows as the Browser, use the Create Query statement.
To change the width, height, or position of a Browser window, use the Set Window statement.
Error Conditions
A runtime error occurs if the Order By clause specifies columns that do not exist in the Browser window, or if the Order By clause attempts to sort using the reserved column names OBJECT or ROWID.
Examples
Dim i_browser_id As Integer
Open Table "world"
Browse * From world
i_browser_id = FrontWindow()
Set Browse Window i_browser_id Row 47
You can use the Set Browse statement to sort up to five columns using the Order By clause.
Set Browse Order By Country, State, City, ZipCode, IncomeGroup
See Also:
Browse statement, Set Window statement