You are on page 1of 7

Opens the Browse window and displays records from the current or selected table.

BROWSE [FIELDS FieldList] [FONT cFontName [, nFontSize [, nFontCharSet]]]


[STYLE cFontStyle] [FOR lExpression1 [REST]] [FORMAT]
[FREEZE FieldName] [KEY eExpression1 [, eExpression2]] [LAST | NOINIT]
[LOCK nNumberOfFields] [LPARTITION] [NAME ObjectName] [NOAPPEND]
[NOCAPTIONS] [NODELETE] [NOEDIT | NOMODIFY] [NOLGRID] [NORGRID]
[NOLINK] [NOMENU] [NOOPTIMIZE] [NOREFRESH] [NORMAL] [NOWAIT]
[PARTITION nColumnNumber [LEDIT] [REDIT]]
[PREFERENCE PreferenceName] [SAVE] [TIMEOUT nSeconds]
[TITLE cTitleText] [VALID [:F] lExpression2 [ERROR cMessageText]]
[WHEN lExpression3] [WIDTH nFieldWidth] [WINDOW WindowName1]
[IN [WINDOW] WindowName2 | IN SCREEN] [COLOR SCHEME nSchemeNumber]

Parameters

FIELDS FieldList

Specifies the fields that appear in the Browse window. The fields are displayed in the order specified in FieldList. You can include
fields from other related tables in the field list. When you include a field from a related table, preface the field name with its table alias
and a period.

If you omit FIELDS, all the fields in the table are displayed in the order they appear in the table structure.

FONT cFontName[, nFontSize [, nFontCharSet]]

Specifies the Browse window's font and font size. The character expression cFontName specifies the name of the font, and the numeric
expression nFontSize specifies the font size. You can specify a language script with nFontCharSet. See the GETFONT( ) Function for
a list of available language script values.

For example, the following clause specifies 16-point Courier font for the fields displayed in a Browse
window:

 
Copy Code
FONT 'Courier',16

If you include the FONT clause but omit the font size nFontSize, a 10-point font is used in the Browse window. If you omit the FONT
clause, 8-point MS Sans Serif is used.

If the font you specify is not available, a font with similar font characteristics is substituted.

STYLE cFontStyle

Specifies the Browse window's font style. If you omit the STYLE clause, the Normal font style is used

If the font style you specify is not available, a font style with similar characteristics is substituted or the
Normal font style is used.

Character Font style


B Bold
I Italic
N Normal
O Outline
Q Opaque
S Shadow
– Strikeout

Wilfredo Apumayta Huillca


T Transparent
U Underline

You can include more than one character to specify a combination of font styles. The following example
opens a Browse window and uses an underlined font:

 
Copy Code
CLOSE DATABASES
OPEN DATABASE (HOME(2) + 'data\testdata')
USE customer && Open customer table
IF _WINDOWS
BROWSE FIELDS contact FONT 'System', 15 STYLE 'NU'
ENDIF
IF _MAC
BROWSE FIELDS contact FONT 'Geneva', 14 STYLE 'NU'
ENDIF
FOR lExpression1

Specifies a condition whereby only records for which lExpression1 is true are displayed in the Browse window.

Rushmore Query Optimization optimizes a query specified with a BROWSE FOR if lExpression1 is an optimizable expression. For
best performance, use an optimizable expression in the FOR clause. For information on Rushmore optimizable expressions, see SET
OPTIMIZE and Using Rushmore Query Optimization to Speed Data Access.

Include FOR to move the record pointer to the first record meeting the condition. Include REST to keep the record pointer at its
current position.

REST

Prevents the record pointer from being moved from its current position to the top of the table when a Browse window is opened with
the FOR clause. Otherwise, BROWSE positions the record pointer at the top of the table by default.

FORMAT

Specifies the use of a format file to control the display and data-entry format in a Browse window. The format file must first be opened
with SET FORMAT. The following information is extracted from the format file and applied to the Browse window:

 The list of fields to browse


 All VALID clauses

 All WHEN clauses

 All RANGE clauses

 Field sizes (as specified in PICTURE clauses)

 All SAY expressions (included as calculated BROWSE fields)

The following example uses a format file to validate data entered into a Browse window. Positions specified with @  ... GET are
ignored.

The first line creates a BROWSE field (cust_id) that is 5 characters wide and allows the entry of letters and digits only. The second
line creates a BROWSE field (company) that cannot contain a blank value and can contain a maximum of 20 alphabetic characters.

The third line creates a BROWSE field (contact) into which you enter data only when the field is blank.

Here are the contents of the Custentr.fmt format file, which is used to validate data entered into the customer table:

 
Copy Code

Wilfredo Apumayta Huillca


@ 3,0 GET cust_id PICTURE 'NNNNN'
@ 3,0 GET company VALID company != SPACE(40) ;
PICTURE 'AAAAAAAAAAAAAAAAAAAA'
@ 3,0 GET contact WHEN contact = SPACE(40)

* This is the program that uses the format file


CLOSE DATABASES
OPEN DATABASE (HOME(2) + 'data\testdata')
USE customer && Open customer table
SET FORMAT TO custentr.fmt
BROWSE FORMAT
FREEZE FieldName

Permits changes to be made to only one field in the Browse window. You specify this field with FieldName.
The remaining fields are displayed but cannot be edited.

 
Copy Code
CLOSE DATABASES
OPEN DATABASE (HOME(2) + 'data\testdata')
USE customer && Open customer table
BROWSE FIELDS phone :H = 'Phone Number:' , ;
company :H = 'Company:' ;
FREEZE phone
KEY eExpression1[, eExpression2]

Limits the scope of records that are displayed in the Browse window. With KEY you can specify an index key value (eExpression1) or
a range of key values (eExpression1, eExpression2) for the records that are displayed in the Browse window. The table you browse
must be indexed, and the index key value or values included in the KEY clause must be the same data type as the index expression of
the master index file or tag.

For example, the customer table includes a character field containing postal codes. If the table is indexed on the postal code field,
you can specify a range of postal codes in the KEY clause.

In the following example, only records with postal codes falling within the range of 10,000 to 30,000 are
displayed in the Browse window:

 
Copy Code
CLOSE DATABASES
OPEN DATABASE (HOME(2) + 'data\testdata')
USE customer && Open customer table
SET ORDER TO postalcode
BROWSE KEY '10000', '30000'
LAST | NOINIT

Saves any configuration changes made to the appearance of a Browse window. The changes are saved in the FoxUser.dbf file and can
include changes to the field list, the size of each field, and the location and size of the Browse window.

If you issue BROWSE with the LAST or NOINIT clause, the Browse window opens in the same configuration that was last saved in
the FoxUser.dbf file if SET RESOURCE is ON. This restores the Browse window configuration created with the last BROWSE
command. If the last BROWSE issued in the Command window included a long list of clauses, issue BROWSE with the LAST or
NOINIT option to avoid having to retype the command. For more information on the FoxUser resource file, see SET RESOURCE.

If the last Browse window was opened with a BROWSE that included a PREFERENCE clause, BROWSE LAST won't restore the
preference.

Any Browse window configuration changes you make in the current session aren't saved if you exit BROWSE by pressing CTRL+Q.

The LAST and NOINIT clauses are identical; NOINIT provides dBASE compatibility.

LOCK nNumberOfFields

Wilfredo Apumayta Huillca


Specifies either a positive number, which indicates the number of fields that you can see in the left partition of the Browse window
without tabbing or scrolling, or a negative number, which indicates the number of fields that remain locked in the Browse window
when tabbing to the right.

The left partition sizes automatically to display the number of fields you specify with nNumberOfFields. A column separator line,
which appears 1 pixel wider than the line separating the other columns, indicates the area where the locked columns end and the
normal columns begin.

LPARTITION

Specifies that the cursor is placed in the first field in the left Browse window partition. By default, the cursor is placed in the first field
in the right partition when the Browse window is opened.

NAME ObjectName

Creates an object reference for the Browse window, allowing you to manipulate the Browse window with object-oriented properties
available for the Grid control. For additional information about object-oriented programming in Visual FoxPro, see, Object-Oriented
Programming. For additional information about the Grid control properties that you can specify for a Browse window created with the
NAME clause, see Grid Control.

NOAPPEND

Prevents the user from adding records to the table by pressing CTRL+Y or by choosing Append Record from the Table menu.

Note
Including NOAPPEND doesn't prevent you from appending a record from within a routine (created with VALID, WHEN, or ON KEY LABEL)
while in the Browse window.
NOCAPTIONS

Specifies to always use the field name of a table or view for the column headers, even when the database contains a friendly caption
for the table field. This clause applies only to tables or views in a database.

NODELETE

Prevents records from being marked for deletion from within a Browse window. By default, a record can be marked for deletion by
pressing CTRL+T, choosing Toggle Delete from the Table menu, or by clicking in the leftmost column of the record to be deleted.

NOEDIT | NOMODIFY

Prevents a user from modifying the table. NOEDIT and NOMODIFY are identical. If you include either clause, you can browse or
search the table, but you cannot edit it. However, you can append and delete records.

NOLGRID

Removes the field gridlines in the left partition of the Browse window.

NORGRID

Removes the field gridlines in the right partition of the Browse window.

NOLINK

Unlinks the partitions in a Browse window. By default, the left and right partitions of the Browse window are linked together so that
when you scroll through one partition, the other partition scrolls.

NOMENU

Removes the Table menu title from the system menu bar, preventing access to the Browse menu.

NOOPTIMIZE

Disables Rushmore Query Optimization of BROWSE. For more information, see SET OPTIMIZE and Using Rushmore Query
Optimization to Speed Data Access.
Wilfredo Apumayta Huillca
NOREFRESH

Prevents the Browse window from being refreshed. Browse windows are refreshed at the rate determined by SET REFRESH.
NOREFRESH is useful with read-only files and improves performance.

NORMAL

Opens the Browse window with its normal default settings, such as its colors, size, position, title, and control options (GROW,
FLOAT, ZOOM, and so on). If you omit NORMAL, and the current output window is a user-defined window with its own settings,
the Browse window assumes those user-defined settings also.

NOWAIT

Continues program execution immediately after the Browse window is opened. The program doesn't wait for the Browse window to be
closed but continues executing on the program line immediately following the program line containing BROWSE NOWAIT. If you
omit NOWAIT when BROWSE is issued from within a program, a Browse window is opened and program execution pauses until the
Browse window is closed.

NOWAIT is available only from within a program. Including NOWAIT when issuing BROWSE from the Command window has no
effect.

PARTITION nColumnNumber

Splits a Browse window into left and right partitions with nColumnNumber specifying the column number of the split bar. For
example, if nColumnNumber is 20, the split bar is placed in column 20 of the Browse window.

LEDIT

Specifies that the left partition of the Browse window appear in Edit mode.

REDIT

Specifies that the right partition of the Browse window appear in Edit mode. This example opens a Browse window with the split bar
placed in column 20 and the right partition open in Edit mode.

Include both keywords to open both partitions in Edit mode.

 
Copy Code
CLOSE DATABASES
OPEN DATABASE (HOME(2) + 'data\testdata')
USE customer && Open customer table
BROWSE PARTITION 20 REDIT
PREFERENCE PreferenceName
Saves a Browse window's attributes and options for later use. Unlike LAST, which restores the Browse window as it appeared in the
previous session, PREFERENCE saves a Browse window's attributes indefinitely in the FoxUser.dbf resource file. Preferences can be
retrieved at any time.
Issuing BROWSE with the specified preference name for the first time creates an entry in the FoxUser.dbf file that saves the Browse
window configuration. Issuing BROWSE later with the same preference name restores the Browse window to that preference state.
When the Browse window is closed, the preference is updated.
Preference names can be up to 10 characters long, must begin with a letter or an underscore, and can contain any combination of
letters, numbers and underscores.
Once you have a preference the way you like it, you can prevent it from being changed. Close the Browse window, issue SET
RESOURCE OFF, open the FoxUser.dbf file as a table, and change the record containing the preference to read-only by changing the
value of the logical field READONLY to true (.T.).
For more information about the FoxUser.dbf resource file, see SET RESOURCE.
If you exit a Browse window by pressing CTRL+Q, no Browse window changes are saved to the resource file.
SAVE

Keeps the Browse window and any of its memo field text-editing windows active and visible (open). You can then return to the
Browse window after cycling through other open windows with the keyboard or the mouse.

SAVE is available only from within a program. SAVE has no effect when included with BROWSE in the Command window because
BROWSE SAVE is always the default in the interactive mode.

Wilfredo Apumayta Huillca


TIMEOUT nSeconds

Specifies how long a Browse window waits for input. The numeric expression nSeconds specifies how many seconds can elapse
without any input before the Browse window automatically closes.

TIMEOUT is available only from within a program; it has no effect when you issue BROWSE from the
Command window. In the following example, the Browse window is closed if no input occurs in 10 seconds.

 
Copy Code
DEFINE WINDOW wBrowse FROM 1,1 TO 24,40 ;
CLOSE ;
GROW ;
COLOR SCHEME 10
CLOSE DATABASES
OPEN DATABASE (HOME(2) + 'data\testdata')
USE customer && Open customer table
BROWSE WINDOW wBrowse ;
FIELDS phone :H = 'Phone Number:' , ;
company :H = 'Company:' ;
TIMEOUT 10
RELEASE WINDOW wBrowse
TITLE cTitleText

Overrides the default table name or alias that appears in the Browse window title bar with the title you specify with cTitleText.
Otherwise, the name or alias of the table being browsed appears in the title bar.

If you issue BROWSE WINDOW to place the Browse window in a user-defined window, the Browse window's
title replaces the user-defined window's title.

 
Copy Code
CLOSE DATABASES
OPEN DATABASE (HOME(2) + 'data\testdata')
USE customer && Open customer table
BROWSE;
TITLE 'My Browse Window' ;
FIELDS phone :H = 'Phone Number' , ;
company :H = 'Company:'
VALID lExpression2
Performs record-level validation in a Browse window. The VALID clause is executed only if a change is made to the record and you
attempt to move the cursor to another record. The VALID clause is not executed if the only change is to a memo field.
If VALID returns a value that is true (.T.), the user can move the cursor to another record. If VALID returns a false value (.F.), the
cursor remains in the current field and Visual FoxPro generates an error message. If VALID returns 0, the cursor remains in the current
field, and an error message isn't displayed.
The VALID clause shouldn't be confused with the verify option (:V), which enables field-level validation.
:F
Forces the VALID clause to execute before the user moves the cursor to the next record. In this case, VALID is executed even if the
record isn't changed.
ERROR cMessageText
Specifies an error message that overrides the system default error message. Visual FoxPro displays cMessageText when VALID
returns false (.F.).
WHEN lExpression3
Evaluates a condition when the user moves the cursor to another record. If lExpression3 evaluates to true (.T.), the user can modify the
record moved to. If lExpression3 evaluates to false (.F.) or 0, the record the user moves to becomes read-only and cannot be modified.
The WHEN clause isn't executed when another window is activated.
WIDTH nFieldWidth
Limits the number of characters displayed for all fields in a Browse window to nFieldWidth. The contents of a field can be scrolled
horizontally using the LEFT ARROW and RIGHT ARROW keys or the horizontal scroll bar. Including the WIDTH clause doesn't
change the size of fields in the table; it alters only the way the fields are displayed in the Browse window. If a width has been specified
for an individual field with the FIELDS clause, it overrides the width specified with the WIDTH clause for that field.
WINDOW WindowName1
Specifies a user-defined window whose characteristics the Browse window assumes. For example, if the user-defined window is
created with the FLOAT clause, the Browse window can be moved. The specified window doesn't have to be active or visible, but it
must be defined.
IN [WINDOW] WindowName2

Wilfredo Apumayta Huillca


Specifies the parent window within which the Browse window is opened. The Browse window doesn't assume the characteristics of
the parent window. A Browse window activated inside a parent window cannot be moved outside the parent window. If the parent
window is moved, the Browse window moves with it.
To access the Browse window, the parent window must first be defined with DEFINE WINDOW and must be active and visible.
IN SCREEN
Explicitly places a Browse window on the main Visual FoxPro window when a user-defined window is active.
COLOR SCHEME nSchemeNumber
Specifies the number of a color scheme used for the Browse window's colors.
The Browse window assumes the color scheme established using the Windows Color Control Panel.

Wilfredo Apumayta Huillca

You might also like