Last Revised: 04/11/19 |
This routine should be used to open a data file. It provides for more complete error checking than normally found within an application, including error 0 (file locked by another task), error 12 (file not defined), and error 18 (insufficient privilege). It also can be used in an environment using both pro5 and bbj by forcing the bbj application to use the pro5 data server. It also supports opening encrypted files.
In addition, CDS095 is able to open a file that is not in the current directory, nor found using the prefix list since it tries to locate the file in the company subdirectory based on the first two characters of the file name. CDS095 also retrieves templates and tracks what files are currently open so that called routines that need to open a file that has already been opened, does not require a disk access, nor open the file more than once.
CDS095 is also used to define and open temporary work files that are described in the Dynamo Data Dictionary.
CALL "CDS095",ERR=XXXX, CHAN, FILNAM$, PAR$, DIMTPL$, KGEN$
Only the CHAN
and FILNAM$
are required to be passed to CDS095.
CDS095 | |||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
ERR
|
Branch to line XXXX if unable to open the file, lock the file, or retrieve the template if so requested by the PAR$ options. |
||||||||||||||||||||||||||||||||||||||||||||||
CHAN
|
Channel# to be used. If passed with a value of zero, then CDS095 will call CDS088 to obtain an available channel and return that channel number to the calling program.
It is Excellware's convention to use a channel variable of the file name (less the company code). For example, a data file named DSCM01 would use a channel number variable of CM01 . If not passed as zero, then the file will be opened to the channel number passed. If there is already a file open to the channel passed, this file will be closed. |
||||||||||||||||||||||||||||||||||||||||||||||
FILNAM$
|
Name of file to be opened. Will be returned including company directory prefix if file was not found in current directory or using prefix. If the
first two characters of the file name are To open an encrypted data file, append two colons and the file encryption password to the file name, i.e., |
||||||||||||||||||||||||||||||||||||||||||||||
PAR$
|
Options which may be passed with values, blanks or as a null string.
|
||||||||||||||||||||||||||||||||||||||||||||||
DIMTPL$
|
Dimensioned template returned by CDS095 to calling program as set by
CDS041. For data files and programs with six
character program names, the convention is to use the file name, less the company code, as the dimensioned template variable. For example, the data file XXCM01 would use CM01$ .
For 5 character programs, the company name is not a part of the program
name, so the convention is to use the entire 5 character program name.
For example, the program GL018 would use GL018$ . |
||||||||||||||||||||||||||||||||||||||||||||||
KGEN$
|
is used in the KGEN() function as the adjusted FIN() data. The KNUM alone, and not +256 option is sufficient since KGEN$ excludes all key segment modification flags such as descending segments, or business math. It is Excellware's convention to use the file name, less the company code followed by a K as the KGEN$ variable. For example, the data file XXCM01 would use CM01K$ . The key derived from the data would be KGEN(DIMTPL$,KGEN$,KNUM). |
Note that files opened by the menu processor use the Excellware convention and assign the channel number, dimensioned template and key generation variables. For example if file XXCM01
is opened by the menu processor, then the application will have the variables CM01
, CM01$
, and CM01K$
already assigned proper values.
Note that CDS095 may be used to open tty devices but not printers. See CDS084 for opening printers.
Should CDS095 fail to open a file for any reason, the error message is returned in the global "SMS_CDS095.ERRMSG".
This is especially useful with background tasks including Dynaweb where the error message cannot be readily displayed.
BBj
Pro5 and bbj use different file locking techniques, so they both cannot
open the same data file at the same time. In a mixed environment where
both pro5 and bbj processes need to access data files simultaneously, you can
set a global variable named SMS_PRE
to the dataserver prefix that bbj should
use such as /<localhost,port=1100>
. When this global is set, CDS095 will
only open data files using a dataserver, either a dataserver contained within
the prefix list, or the dataserver prefix specified by the global variable.
This global can also be specified using the background
script or by the cgi script to enable Dynaweb applications to use
bbj.
Examples
Opening a non-templated data file using default options. The
application will use the numeric variable SK00 to access the file.
If the numeric variable SK00 is zero, then CDS095 will set SK00 to an
unused channel number. If SK00 has a non-zero value when passed to
CDS095, then CDS095 will use the value passed, and close the file
currently opened to this channel. |
CALL "CDS095",ERR=XXXX,SK00,"XXSK00"
|
Opening a templated data file using default options. |
CALL "CDS095",ERR=XXXX,CM01,"XXCM01","",CM01$
|
Typical data file READ statement: |
READRECORD (CM01,KNUM=0,KEY=CUSTNO$,DOM=XXXX)CM01$
|
Typical data file WRITE statement: |
WRITERECORD (CM01)CM01$
|
Opening a templated data file using default options with KGEN
field. |
CALL "CDS095",ERR=XXXX,,"XXVM60","",VM60$,VM60K$
|
Typical data file REMOVE statement. The advantage of using
the KGEN function on the REMOVE , is that the program becomes
independent of the file's key structure. If the key structure
is changed, then the program does not need to be changed. |
REMOVE (VM60,KEY=KGEN(VM60$,VM60K$,0))
|
Opening a data file within a called routine which may be called
more than once. The "U" parameter will return CM01 with the
channel number if the file is already opened, eliminating any disc
access on subsequent calls. If the XXCM01 file is not already
opened, then CDS095 will open it and assign the channel variable
CM01 . |
CALL "CDS095",ERR=XXXX,CM01,"XXCM01","YUY",CM01$
|
Opening and locking a templated data file. |
CALL "CDS095",ERR=XXXX,CM01,"XXCM01","YYY",CM01$
|
Defining a temporary work file based on file definition stored
in the data dictionary. The data dictionary file name must
include a trailing period (VM040. ), but it is not included in the FILENAME$ passed to CDS095. In this example, the data
dictionary company DY was used since the VM040 program was located
in the DY/ directory. |
READY
|
Defining a temporary work file where the company code is
included in FILENAME$ . The EX data dictionary is used in this
example with a file name of "T220." . |
READY
|
Example opening an encrypted file |
CALL "CDS095",PR01,"XXPR01::MyPassword","YNY",PR01$
|