How to Browse with Mixed Read-Only and Read/Write Fields

ID: Q107195

The information in this article applies to:

SUMMARY

The BROWSE FREEZE command allows a single field in a Browse window to be modified, with the remainder of the fields automatically browsed as read- only fields. It is often desirable to have a mixture of several fields that are read-only and several fields that are read/write in the Browse window. There are three methods (described below) that can be used to accomplish this.

MORE INFORMATION

The three methods below browse the FOXPRO\TUTORIAL\CUSTOMER database, with the CNO, COMPANY, and YTDPURCH fields being read-only, and the CONTACT, ADDRESS and CITY fields being read/write.

Method 1: Using the BROWSE FORMAT Command

A format file can be used to control the Browse window. The row and column positions are not important. To browse a read-only field, place an @ ... SAY <field> command in the file. To browse a read/write field, place an @ ... GET <field> command in the file. If a read/write field has a PICTURE, WHEN, or VALID clause associated with it, add the clause at the end of the @ ... GET command in the format file.

1. Create a format file using the following command:

      CREATE FILE customer.fmt

2. Place the following commands in the format file:

      @ 1,1 SAY cno
      @ 2,2 SAY company
      @ 3,3 SAY ytdpurch
      @ 4,4 GET contact
      @ 5,5 GET address
      @ 6,6 GET city

3. Save the file and issue the following command to activate the format
   file:

      SET FORMAT TO customer.fmt

4. Issue the following command to begin the browse:

      BROWSE FORMAT

5. After the browse is complete, deactivate the format file with the
   following command:

      CLOSE FORMAT

Method 2: Using Calculated Fields on the BROWSE STATEMENT

The second method involves using a calculated field on the BROWSE command itself for each read-only field desired. This method takes fewer steps; however, it requires that a calculated field name be created for each read- only field. For example, issue the following command:

   BROWSE FIELDS ;
      custno=cno, companynm = company, yrlypurch = ytdpurch, ;
      contact, address, city

Method 3: Using the :R Option with a Fields List

The third method involves using a read-only (:R) specifier for each field that should be read-only. For example, issue the following command:

   BROWSE FIELDS ;
      cno:R, company:R, ytdpurch:R, ;
      contact, address, city

Additional reference words: FoxDos FoxWin 2.00 2.50 2.50a 2.50b locked multiple many KBCategory: kbprg KBSubcategory: FxprgBrowse

Last Reviewed: June 27, 1995