Set main file

Command group Flag affected Reversible Execute on client Platform(s)
Files NO YES NO All


Set main file {file-name}


This command selects the "main file" class. Set main file is an essential command which you must execute before manipulating any data. You can insert or delete data only in the file designated as the main file. The designated file cannot be memory-only or closed.

The main file setting also determines which connected files are located when finding records with Find/Next/Previous, and which connections are updated. As each main file record is read, the connected records are automatically read in and made available for editing. When the main file is edited or inserted, all connections to its parent files are updated, unless the parent file is closed.

If Omnis attempts to execute a command which requires a main file before the main file is set, an error occurs. If the data file is not opened when the main file is set, Omnis will try to open the default data file and, if this is unsuccessful, will display the Change data file dialog box so that the user can select or create a data file.

Changing the main file after a Prepare for... command does not cancel Prepare for mode. When an update is encountered, the main file set at the time of the last Prepare for is used. (See Prepare for edit, Prepare for insert.)

If you use Set main file in a reversible block, the main file is reset to its previous value when the method containing the reversible block finishes.

Multiple open data files

If more than one data file is open, there is only one main file setting shared by all open data files. If you do not qualify a file class name with a data file, the current data file is assumed unless you have created an association between the file class and another data file using the Set default data file command.


; Set the main file in a reversible block so it returns to
; it's former setting once this method terminates
Begin reversible block
  Set main file {fAccounts}
End reversible block
Prepare for insert
Calculate fAccounts.Code as 'AC01'
Calculate fAccounts.Surname as 'Smith'
Calculate fAccounts.Balance as 100
Update files