CDS187

Return File Information

Last Revised: 10/30/15

This called program is used to obtain information about an opened channel or file name, including data files, programs, SELECT channels, pipes, etc.

CDS187 replaces CDS087 and returns a template containing a comprehensive set of information about a file.

Calling Format:

CALL "CDS187", ERR=XXXX, CHAN, S187$, KEYDEF$

or

CALL "CDS187", ERR=XXXX, Y$, REC$, S187$

ERR=XXXX Branch to line XXXX if there is no file opened to channel CHAN or when using the second format, if CDS187 is unable to open the specified file.  There is no user prompt except when the FID() function returns an error other than 14.
Input Data Elements
CHAN

Channel/device number of file, program, or device currently opened.  CHAN and the CDS187.MODE global variable are used to indicate whether CDS187 should perform complete, or limited function.  The CDS187.MODE global value is based on the 'Limit CDS187 output' parameter in Dynamo Configuration Maintenance (SMC).

CDS187.MODE global CHAN CDS187 function
not set positive complete
negative (Negate actual channel#) partial
set to "part" positive and under 100,000 and Y.APPID$(1,2)<>"CD" partial
negative (Negate actual channel#) partial
over 100,000 (Add 100,000 to actual channel#) complete

The following output fields are not populated when CDS187 runs in 'partial' mode (in order to save processing time, context switches, disc I/O, etc).

  • COCODE, DDNAME, OWNER, GROUP, PERMISSIONS, READONLY, LINKNAME, DESC and LISTING fields,
  • RECSUSED on IND files,
  • All programs will return TYPE as PGM, regardless of level and encryption,
  • FILESIZE and SIZE will also not be accurate for files larger than 4Gb.
Y$ Session control variable.  When using the second format, CDS187 will add Y.COMPCODE$ to the front of the file name from REC$.
REC$ When using the second format, CDS187 will return information about a file name REC.FILNAM$ or REC.FILENAME$
Output Data Elements
S187.TYPE$
DIR Direct Disc File
EPG Encrypted Program (current BBx version)
EP? Encrypted Program (? represents BBx version. 4=bbx progression 4, 5=pro5, 6=bbj)
FTS Full Text Search
IND Indexed Disc File
SRT Sort Disc File
SER Serial Disc File
PGM Program (current BBx version)
PG? Program (? represents BBx version, 4=bbx progression 4, 5=pro5, 6=bbj)
DEV Device
DRY Disc Directory
PIP Pipe to operating system command
SEL Data file opened using SELECT verb
SCK Socket (SKT on versions before 07/02/2011)
STR String File
SKY BBx Multi-Keyed File (Single key version)
SKX BBj Xkeyed File (Single key version)
SKJ BBj Jkeyed File (Single key version)
SKV BBj VKeyed File (Single key version)
MKY BBx Multi-Keyed File (Multiple key version)
MKX BBj Xkeyed File (Multiple key version)
MKJ BBj Jkeyed File (Multiple key version)
MKV BBj Vkeyed File (Multiple key version)
??? Other (unknown file type)
S187.OPTS$ File options including any of the following codes.
HIndicates file is in the BBx Highly Recoverable Format, recommended for all data files to improve file error recovery
LIndicates file is defined with the Large BBx option indicating it can grow larger than 2Gb.  Only recommended for such large files, since the pointers are 64 bits long, as opposed to 32 bits for regular files, which increases file size.
4Indicates the older 4Gb BBx file size option, used in BBx version prior to 3.0
NIndicates the BBj program does not have line numbers
S187.KEYSIZE Returns the key size of DIR, SRT, SKx files, and on MKx files, the key size of the primary knum.
S187.RECSIZE Returns the record size of DIR, SKx, IND and MKx files.  Returns 0 for SRT files, and SKx files with zero characters per record.
S187.RECSMAX Returns the maximum number of records for DIR and SRT files.  Also may apply to IND, SKx and MKx files if number of records are limited.
S187.RECSUSED Returns the number of records is use for DIR, SRT, SKx, and MKx files.  For IND files, RECSUSED contains the actual number of records (if the file is dynamic), or the same as RECSMAX (if not dynamic).
S187.FILESIZE The total number of characters in a disc file.  For files over 2Gb in size, this number may be inaccurate on Windows file systems or when CHAN is negative.
S187.SIZE$ The total file size formatted to take 7 characters.  Mb represents 1,000,000 not 1,024,000.  Gb represents 1,000,000,000 not 1,024,000,000.
File size < 1MbActual File size ###,##0
File size < 1Gb###.0Mb
Larger###.0Gb
S187.PCTFULL For non-dynamic files, PCTFULL will indicate the percentage of records in use.
S187.MAXKNUM For MKx files, this will indicate the maximum KNUM for the file.  Dynamo Tools support files with up to 254 KNUM's which is less that the maximum supported by BBj.
S187.ACTKNUM For MKx files, this will indicate the active KNUM for the file.
S187.ACTKEYSIZE For MKx files, this will indicate the total number of characters in the active KNUM for the file.
S187.DATE For programs and data files, DATE contains the BBx julian date when the file was last modified.  Use the BBx DATE() function to format.
S187.TIME For programs and data files, TIME contains the time when the file was last modified.  It is in hours and fractions of an hour.  Use the BBx DATE() function to format.
S187.LOCKED
0 File not currently locked
1 File currently locked
2 File cannot be locked (DRY type)
S187.COCODE$ S187.COCODE$ indicates the Dynamo Tools two character company code, based on the file path name or current PREFIX.

If the relative file name is located in a folder with a 2 character name, such as DY/, CD/, or a sub-folder below a 2 character folder name such as PY/PGM/ or RL/PROG/ then the company code is the two character folder name.

In other cases including files located in a temporary job folder such as J/12345/FILENAME, or across a data server with a file name such as /<server,pro5srv>/usr/data/FILENAME, or a folder on a different file system such as /usr8/data/FILENAME, the company code is derived by checking for the base file name located in any of the relative two character folders specified in the PREFIX, such as DS/ CD/ RL/ PY/ etc.  If the base file name is located, then the company code will indicate this folder name.

If the file is not found in any of these locations, then the current company code is returned in S187.COCODE$.

For data files, S187.COCODE$ is typically used to determine the company code for the data dictionary.  For program files, S187.COCODE$ is used to determine the company code for the DD90, DD91, and DD92 data dictionary files which are used to store called program arguments and program revision notes.  Note that programs may also have a regular data dictionary entry, but in that case S187.COCODE$ will reflect the DD90/DD91/DD92 company code and not the DD10 company code.

S187.BASENAME$ Contains the base name for disc files, which excludes all drive letters and path.
S187.RELNAME$ Contains the relative file name, relative to the SMSDIR base directory.  If the file is not below the SMSDIR directory, then S187.RELNAME will be the same as S187.FULLNAME. When using the !DSOPEN global to access a bbj pro5 data server, S187.RELNAME$ will not include the data server prefix.
S187.FULLNAME$

Contains the full path name including drive letter on Windows systems.

When using the pro5 !DSOPEN global, the data server prefix will not be included unless STBL("!DSNOHIDEFID")="1".

S187.DDNAME$ Contains the data dictionary name.  It is similar to the BASENAME but will exclude the company code when the data file name includes the company code.
S187.OWNER$ The owner of the file, if available on this operating system.
S187.GROUP$ The group of the file, typically only available on non-Windows operating systems.
S187.PERMISSIONS$ The file permissions, typically only available on non-Windows operating systems.  In the format rwxrwxrwx where the first rwx applies to the file owner, the second to others in the same group, and the third to those in other groups.  The r indicates read, the user can read the file.  The w indicates write, the user has permission to write to the file.  The x indicates execute, and applies to executable files (binary, not programs), and to directories.  The x permission in a directory is required to enable accessing file in that directory.  If permission is not granted, then the r, w, or x, are replaced with "-".
S187.READONLY On Unix like systems, S187.READONLY will be 1 if the current user does not have write permissions to the opened file or device.  This can be used by applications to enable a read-only mode and bypass any WRITE's that would cause a bbx error 13 or 18.
S187.LINKNAME$ On Unix like systems, if the file is a symbolic link, then S187.LINKNAME$ will be the 'linked to' file name.
S187.DESC$ DESC$ contains file descriptive information that varies depending on the file type:
DIR, IND, SRT, SER, SKx, MKxFile description as obtained from Dynamo Data Dictionary
EPG, EP?File description as obtained from the Called Program Data Dictionary (XXDD90) or "Encrypted Program"
PGM, PG?First remark found in program, or "*** Uninitialized Program ***", or "*** No Remark ***", or "BBx Progression ?/ format program"
DEVDevice name from FIN()
DRYempty
PIP"Pipe"
SELempty
SCK"Socket"
STRFor text files, DESC$ will contain the first few characters of the file, excluding any line feeds.  For binary files on Unix like systems, DESC$ will contain the information available using the "file" command.
LISTING$ When running BBj, this variable will be set to the program statements separated by line feeds for all PG5 and PGM file types.
KEYDEF$ KEYDEF$ will contain the key definition data for MKx data files.  KEYDEF$ can be passed to CDS064 to specify the key structure when defining a file.  KEYDEF$ is similar, but not exactly the same as the BBx FIN() function.  Note that all files use the 8 character FIN() format, even bbj files that would require the 20 character XFIN() format to describe the key structure for MKX, MKJ, and MKV files.  This imposes some limits on possible key structures when used with Dynamo Tools, including a maximum of 256 KNUM's, maximum field# of 255, maximum field offset of 65,535, and a maximum key segment length of 255 characters.
Example
1200 EXAMPLE:
1210 CALL "CDS095",CM01,"DSCM01"; REM "Open data file
1220 CALL "CDS187",CM01,S187$; REM "Request File information
1230 CALL "CDS279",S187$; REM "Display data structure
 

Example demonstrating the difference between a positive and negative channel#
OPEN (1)"DSCM01"
CALL "CDS187",1,S187$
CALL "CDS187",-1,S187A$
CALL "CDS279",S187$,S187A$