|Navigation: Language Reference > 13 - Built-in Functions >====== OPEN (open a data structure) ======|
OPEN( entity [, access mode / owner ] )
|OPEN||Opens a FILE, VIEW, APPLICATION, WINDOW, or REPORT structure for processing.|
|entity||The label of a FILE, VIEW, APPLICATION, WINDOW, or REPORT structure.|
|access mode||A numeric constant, variable, or expression which determines the level of access granted to both the user opening the FILE entity, and other users in a multi-user system. If omitted, the default value is 22h (Read/Write + Deny Write). Valid only when the entity parameter names a FILE structure.|
|owner||The label of the APPLICATION or WINDOW structure which “owns” the window entity being opened. Normally, this parameter would be an &WINDOW reference variable. Valid only when the entity parameter names an APPLICATION or WINDOW structure.|
The OPEN statement opens a FILE, VIEW, APPLICATION, WINDOW, or REPORT structure for processing.
The OPEN statement opens a FILE structure for processing and sets the access mode. Support for various access modes are file driver dependent. All files must be explicitly opened before the records may be accessed.
The access mode is a bitmap which tells the operating system what access to grant the user opening the file and what access to deny to others using the file.
The actual values for each access level are:
Dec Hex Access
0 0h Read Only
1 1h Write Only
2 2h Read/Write
0 0h Any Access (FCB compatibility mode)
16 10h Deny All
32 20h Deny Write
48 30h Deny Read
64 40h Deny None
The OPEN statement opens a VIEW structure for processing. A VIEW must be explicitly opened before it may be accessed. The files used in the VIEW must already be open.
Before the OPEN(view) statement, you may issue a SET statement to the VIEW structure's primary file to setup sequential processing for the VIEW. You cannot issue a SET statement to the primary file while the VIEW is OPEN–you must CLOSE(view), then issue the SET,and then OPEN(view) again. SET(view) may be issued while the VIEW is open to setup sequential processing using the ORDER attribute.
OPEN activates an APPLICATION or WINDOW for processing. However, nothing is displayed until a DISPLAY statement or the ACCEPT loop is encountered. This allows an opportunity to execute pre-display code to customize the display.
A window with an owner always appears on top of its owner, and is automatically hidden if the owner is minimized or hidden. If the owner is closed, all owned windows are also automatically closed. MDI windows are implicitly owned by the frame window. Non-MDI windows do not have an owner by default.
OPEN activates a REPORT structure. You must explicitly OPEN a REPORT before any of the structures may be printed.
|02||File Not Found|
|03||Path Not Found|
|04||Too Many Open Files|
|32||File Is Already Locked|
|36||Invalid Data File|
|38||Invalid Key File|
|45||Invalid File Name|
|46||Key Files Must Be Rebuilt|
|47||Invalid File Declaration|
|52||File Already Open|
|57||Invalid Memo File|
|73||Memo File is Missing|
|75||Invalid Field Type Descriptor|
|79||Unsupported Data Type In File|
|88||Invalid Key Length|
|90||File System Error|
|92||Build In Progress|
ReadOnly EQUATE(0) !Access mode equates
Header FILE,DRIVER('Clarion'),PRE(Hea) !Declare header file layout
Detail FILE,DRIVER('Clarion'),PRE(Dtl) !Declare detail file layout
ViewOrder VIEW(Header),ORDER('+Hea:OrderNumber') !Declare VIEW structure
JOIN(Dtl:OrderKey,Hea:OrderNumber) !Join Detail file
OPEN(Names,ReadWrite+DenyNone) !Open fully shared access
SET(Hea:AcctKey) !Set to primary file
OPEN(ViewOrder) !then Open view
SET(ViewOrder) !or SET(view) after opening
!to use ORDER attribute
OPEN(CustRpt) !Open a report
OPEN(Win1) !Open the window
GlobalWindowReference &= Win1 !Assign window reference to a
IF EVENT() = EVENT:AlertKey
OPEN(Win2,GlobalWindowReference) !Open Win2, “owned” by Win1