User Tools

Site Tools


open_open_a_data_structure_.htm
Navigation:  Language Reference > 13 - Built-in Functions >====== OPEN (open a data structure) ====== Previous pageReturn to chapter overviewNext page

OPEN( entity [, access mode / owner ] )

blk2blue.jpg

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.

FILE Usage

black.jpg

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

User Access:

0    0h   Read Only

1    1h   Write Only

2    2h   Read/Write

Other's Access:

 0   0h   Any Access (FCB compatibility mode)

 16  10h  Deny All

 32  20h  Deny Write

 48  30h  Deny Read

 64  40h  Deny None

VIEW Usage

black.jpg

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.

Window Usage

black.jpg

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.

REPORT Usage

black.jpg

OPEN activates a REPORT structure. You must explicitly OPEN a REPORT before any of the structures may be printed.

Errors Posted:

02 File Not Found
03 Path Not Found
04 Too Many Open Files
05 Access Denied
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

Example:

ReadOnly    EQUATE(0)                           !Access mode equates

WriteOnly   EQUATE(1)

ReadWrite   EQUATE(2)

DenyAll     EQUATE(10h)

DenyWrite   EQUATE(20h)

DenyRead    EQUATE(30h)

DenyNone    EQUATE(40h)

Header   FILE,DRIVER('Clarion'),PRE(Hea)        !Declare header file layout

AcctKey   KEY(Hea:AcctNumber)

OrderKey  KEY(Hea:OrderNumber)

Record    RECORD

AcctNumber   LONG

OrderNumber  LONG

ShipToName   STRING(20)

ShipToAddr   STRING(20)

         END

        END

Detail    FILE,DRIVER('Clarion'),PRE(Dtl)        !Declare detail file layout

OrderKey   KEY(Dtl:OrderNumber)

Record     RECORD

OrderNumber LONG

Item        LONG

Quantity    SHORT

          END

         END

ViewOrder VIEW(Header),ORDER('+Hea:OrderNumber') !Declare VIEW structure

          PROJECT(Hea:OrderNumber)

          JOIN(Dtl:OrderKey,Hea:OrderNumber)    !Join Detail file

           PROJECT(Det:Item,Det:Quantity)

          END

         END

CODE

OPEN(Names,ReadWrite+DenyNone)                  !Open fully shared access

OPEN(Header)

OPEN(Detail)

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

Win1Proc PROCEDURE

Win1 WINDOW,ALRT(F10Key)

    END

CODE

OPEN(Win1)                                      !Open the window

GlobalWindowReference &= Win1                   !Assign window reference to a

                                                !global &WINDOW

ACCEPT

 IF EVENT() = EVENT:AlertKey

  START(Win2Proc)

 END

END

Win2Proc PROCEDURE

Win2 WINDOW

    END

CODE

OPEN(Win2,GlobalWindowReference)                !Open Win2, “owned” by Win1

ACCEPT

END

See Also:

SHARE

CLOSE

SET

EXISTS

FILE

VIEW

APPLICATION

WINDOW

REPORT

ACCEPT

DISPLAY

CLOSE

open_open_a_data_structure_.htm.txt · Last modified: 2021/04/15 15:57 by 127.0.0.1