Partilhar via


FoxUser Resource File Structure

The FoxPro resource file FoxUser.dbf holds a variety of resource information (for example, window positions, color sets, Browse window configurations, label definitions, and so on.). FoxUser.dbf is a standard FoxPro table with an associated memo file (.FPT). If the index file does not exist, it is created when the FoxUser.dbf file is opened.

Unlike in earlier versions of Visual FoxPro, the FoxUser.dbf resource file is opened SHARED

While RESOURCE is SET ON, FoxPro handles all resource management. You can modify the data contained in this file in two ways:

  1. Special window configurations or other window preferences, once established and saved in the resource file, can be protected from subsequent interactive changes by modifying the READONLY field for the specific resource (see the example in the Predefining Browse Window Configuration section).
  2. Resources that are no longer needed or wanted may be deleted and the resource file may be packed.

Modifying the READONLY field and/or deleting records from the resource file are the only actions you should perform on the FoxUser.dbf file. You should make a copy of the resource file before making any modifications.

The FoxUser.dbf table has the following structure:

Field Field Name Type Width
1 TYPE Character 12
2 ID Character 12
3 NAME Memo 4
4 READONLY Logical 1
5 CKVAL Numeric 6
6 DATA Memo 4
7 UPDATED Date 8
  • TYPE
    Identifies the type of information the resource holds
  • ID
    Identifies the record with the TYPE
  • NAME
    Contains the name assigned to the resource, for instance the name assigned to color sets, BROWSE windows, and system windows
  • READONLY
    A logical field that can be set to true (.T.) to indicate that the resource should be used for read-only access and cannot be changed
  • CKVAL
    Used by FoxPro to verify the data (in the memo field DATA) is valid
  • DATA
    Memo field that holds the actual data for the resource
  • UPDATED
    The date the current resource was last changed

You can make the FoxUser.dbf resource file read-only by marking it at the MS-DOS level. The MS-DOS command ATTRIB uses the <+R> setting to mark a file as read only. Marking a file read-only is useful in multiuser situations, because the FoxUser.dbf can be shared on a network.

Modifying the FoxUser.dbf Resource File

The following SET RESOURCE commands make it possible for you to open and easily modify the FoxUser.dbf file's contents, as well as use a resource file other than FoxUser.dbf.

SET RESOURCE TO <resourcefile>

SET RESOURCE TO

SET RESOURCE ON

SET RESOURCE OFF

If you want to make changes to your resources, in the Command window, use the following commands:

SET RESOURCE OFF
USE FOXUSER
BROWSE

With the resource file open, you can use CHANGE, EDIT, BROWSE, DELETE, REPLACE and other FoxPro commands to modify or delete data. You can even use COPY TO to create a new resource table. When you have finished modifying the resource file, pack it if you marked records for deletion, and close it. Then, set the resource feature on with the following commands:

USE
SET RESOURCE ON

You can open the FoxUser.dbf file in a work area without setting resource OFF by issuing the command USE SYS(2005) AGAIN. SYS(2005) returns the name of the current resource file.

Predefining Browse Window Configuration

One useful modification that you can make to the FoxUser.dbf file is changing the READONLY field for predefined Browse window configurations.

First, adjust a BROWSE window to display specific fields that are sized for easy manipulation, position the window and size it, split the window into two partitions, with one partition in BROWSE mode and one in CHANGE, then close the window. When the BROWSE window is closed, its configuration is saved in the current resource file, provided the field named READONLY is not set to T, and provided the window was not closed with Ctrl+Q.

Then, issue USE SYS(2005) AGAIN and edit the READONLY field, setting it to true ("T"). To do this, look for the BROWSE window resource that has a TYPE of PREFW, and ID of WINDBROW, and a NAME field with the alias of the table you just browsed. When the READONLY field is true (T), the corresponding resource data will not be overwritten if the Browse window configuration is later changed interactively.

Now, whenever the table is browsed with the BROWSE LAST command, the Browse window appears in the same position with all its field, size, and placement configurations the same as the last session. No matter how much the Browse window is changed by the user, it will always return according to the data in the resource when you BROWSE LAST.

See Also

Resource Files in Applications | Visual FoxPro Configuration