| Directives |
|
| Formats | 1.
Open
File/Device Channel: OPEN (chan[,fileopt])
[ TABLE ] string$ 2. Open for Read-Only Mode: OPEN INPUT(chan[,fileopt]) [ TABLE ] string$ 3. Open Locked: OPEN LOCK (chan[,fileopt]) [ TABLE ] string$ 4. Open Locked and Pre-Cleared: OPEN PURGE (chan[,fileopt]) [ TABLE ] string$ 5. Open Static Keyed File Read Only: OPEN LOAD (chan[,fileopt]) [ TABLE ] string$ 6. Open File for Use in Object (OOP): OPEN OBJECT (chan[,fileopt]) [ TABLE ] string$ 7. Open Dictionary: OPEN DICTIONARY [ DIRECTORY ] string$ 8. Compatibility mode Open: OPEN+ (chan[,fileopt]) [ TABLE ] string$ Where:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Description | Use
this directive to open a file or device and assign a
logical file number to it.
If you use a channel that is already OPEN, ProvideX returns an Error#14. If you try to OPEN a file that doesn't exist, it returns an Error #12: File does not exist (or already exists). In some circumstances (e.g., in trying to OPEN a printer twice), an Error#0 is generated.
Use the OPT= parameter to define options for Windows COM ports. That is, in the Windows environment you can specify communications port settings for COM ports by adding, for example, OPT="9600,n,8,1,x" where the values represent baud rate, parity, data bits, stop bits and xon/xoff flow control. See also COM Ports and Serial Devices . |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| *Note* | If you do not use the OPT= option for communications settings, ProvideX will default to the setup in the Windows Control Panel. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Use
the IOL= option to define a standard
IOList to be used while the file is open. ProvideX will
use this IOList for all subsequent file READ,
WRITE, EXTRACT, or FIND
statements where you do not explicitly supply
variable lists. You can also use the REC=
option to supply a prefix to be added to all the
variables in the IOL= specification. If the ISZ= option is used, ProvideX opens the file in binary mode. That is, ProvideX makes no attempt to analyze the file structure or contents. All subsequent access to the file / channel is done as if the file is an indexed file with a record size equal to the value set in the ISZ= option. With ISZ=1, a READ RECORD directive will return 1 byte at a time (each logical record is 1 byte). For ISZ=1024, the data is returned 1024 bytes at a time, with the first 1024 bytes in IND=0, the next 1024 bytes in IND=1 and so on. You can gain access to the file sequentially or by using the index. A negative value notifies ProvideX to return up to the given number of bytes. If you use ISZ=-1, ProvideX will not append record terminators to output lines printed to a file without a hanging comma. (Normally ProvideX appends a line feed to the end of such output lines in UNIX, or a carriage return and line feed in Windows and to the end of every record written to a serial file.) If you use the BSZ= option, file access will be buffered in a buffer equal to the size you set for the option. OPEN with PREFIX FILE Definition You can have two fields in a prefix file data record. (A prefix file is a special Keyed file that contains information used when a file.) The first of the two fields is the path/filename of the real file to open. The second is an options field. ProvideX uses any options in this field as the OPT= values when opening the real path/filename. When opening a filename assigned in a prefix file directive, you can include additional OPT= values in the OPEN directive to have ProvideX append these as additional options for the true file being opened (i.e., the filename in the prefix file record). Given a prefix file record containing:
If you OPEN(chan)"GLMAST" then internally ProvideX will issue:
If you OPEN(chan,OPT="REC=somedata")"GLMAST" then internally ProvideX will issue:
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| TABLE option | The
keyword TABLE before the string$ indicates that
the value provided is the logical table name for the file
as defined in the currently opened Data Dictionary file.
See OPEN DICTIONARY below for more details
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| See Also | CLOSE
Directive, OPT( ) Function, PREFIX Set File Search Rules PASSWORD Apply Password & Encryption Special Command Tags, |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Format 1 | Open File/Device
Channel
The given file or device must be opened before the program can gain access to it. You can normally have a maximum of 127 files open at any time in a ProvideX session (less under some operating systems). In the extended file access mode 'XF' you can open up to 65000 files, subject to OS limitations. In Windows use a colon (:) at the end of a filename to open an LPTn port number directly. For instance, LPT1 and LPT1: are considered to be the same device. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| *Note* | The actual number of files you can open at any one time depends on operating system parameters. Consult your system configuration information for details on how to increase the number of files you can open. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Example 2:
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Format 2 | Open for Read-Only Mode
If you use the OPEN INPUT format, the program can't update the file (opened as read-only). Use this format to open a disk directory or to access files with read-only permissions. The OPEN INPUT directive under UNIX will not lock a text mode device. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Format 3 | Open Locked
Using this format, the file is reserved for exclusive use prior to the OPEN. However, if another user already has the file OPEN, the LOCK format of the directive fails and ProvideX returns an Error #0: Record/file busy. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| *Note* | Under UNIX, /dev/null and /dev/console files are not locked when opened. However, all other files are. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
WindX Example:
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| *Note* | WindX supports the use of SERIAL and ERASE commands via the [WDX] tag. It is not necessary to embed these commands in an EXECUTE directive. (If you are running a version of ProvideX earlier than Version 4.20 on a WindX PC, you may need to encapsulate these commands in an EXECUTE "[WDX]..." directive, as in lines | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Format 4 | Open Locked and
Pre-Cleared
If you use the OPEN
PURGE format, the file will be locked and
pre-cleared (purged) |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Format 5 | Open Static Keyed File
Read Only
With the OPEN LOAD format, ProvideX assumes that the file is a static Keyed file and opens it for READ access only. ProvideX assumes that the file is a static Keyed file; i.e., no other task on the system will update this file. Whenever a portion of the file's key structure is read into memory, ProvideX keeps it in memory until you CLOSE the file. ProvideX gives you extremely fast access to static files by reducing the disk I/O and effectively caches the file in memory. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Format 6 | Open File for Use in
Object (OOP)
In Object Oriented Programming, the OPEN OBJECT directive indicates that a file being opened is for the exclusive use of an object. Only the object itself can alter the state of the file, and once the object is deleted, the file is automatically closed. Any external attempt to alter the state of the file returns Error #13: File access mode invalid. The file is not closed on an external BEGIN. It will only be closed when the object is deleted, or by an explicit CLOSE (chan) from within the object. FFN and other file functions will not see the file while outside of the object thus cannot effect its position or other characteristics.e; however, system variables like HFN and CHN will reflect that the file is open, and some functions (PTH, FIN, FIB, etc.) can be used to query file attributes.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| The
file is opened in the ON_CREATE. There is no need to
worry about closing the file since ProvideX does it
automatically. Refer to the following functions and directives for related information on Object Oriented Programming: |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| For Oobjects See Also: | DEF CLASS Define Object Class
PROPERTY Declare Object Properties FUNCTION Declare Object Method LIKE Inherit Properties PROGRAM Create/Assign Program File RENAME CLASS Change Name of Class STATIC Add Local Properties at Runtime DROP OBJECT Delete Object NEW( ) Function REF( ) Function |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Format 7: | OPEN
DICTIONARY
If desired, files can be referenced by their logical table, as opposed to their physical file pathname. Before referencing file by their table name, you must define where the Data Dictionary is in the system by using the OPEN DICTIONARY directive. For Example:
The value in string$ should be either the pathname of the 'providex.ddf' file or the pathname of the directory in which the 'providex.ddf' file exists. If no string$ is provided, the current directory is assumed to contain the dictionary file. The function PTH(*DICTIONARY) can be used to determine the current Dictionary being used.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Format 8: | OPEN+
Compatibility Mode open
The compatibility mode OPEN+ directive is designed to simplify the conversion of applications from BBx®. It provides the following functionality:
The conversion utility *conv.bbx/cv_gui has been enhanced as of build 9163 of PxPlus to allow for the automatic translation of all OPEN directives to OPEN+.
BBx® is registered trademarks of BASIS International Ltd. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||