Titus Information Systems, Inc.

Standard Library
CDataFile Class

This base class provides a standard interface from a Visual C++ function to a COBOL routine that handles indexed-sequential file I/O to a database file.  If the MicroFocus NetExpress COBOL compiler is used, the data files may be accessed with either the proprietary indexed-sequential file system shipped with NetExpress or Pervasive SQL.  The linkage section is as follows:

        LINKAGE SECTION.
        01  FUNCTION-KEY        PIC S9999 USAGE COMP-5.
        01  FILE-RECORD.
            03  PRIMARY-KEY     PIC X(key-length).
            03  FILLER          PIC X(rec-length).
        PROCEDURE DIVISION USING FUNCTION-KEY, FILE-RECORD.
        DETERMINE-KEY.
            GO TO OPEN-READ, OPEN-WRITE, OPEN-BOTH, CLOSE-FILE,
                START-READ, READ-NEXT, READ-RECORD, ADD-RECORD,
                UPDATE-RECORD, DELETE-RECORD, COMMIT-FILE,
                VALIDATE-DATA, DEPENDING ON FUNCTION-KEY.
This class must be inherited by a class that defines the variables in the constructor.  The member functions and variables are as follows:
CDataFile::CDataFile()
This is the constructor.  It initializes the data members.
BOOL CDataFile::Open(CString FileName, char UserAccess)
This member function calls the File I/O function with FileName in the FILE-RECORD buffer.  Note that the FILE-RECORD buffer will be blank filled to 160 characters.  FUNCTION-KEY will be set depending on UserAccess: R (read) = 1, W (write) = 2, and B (both) = 3.
void CDataFile::Close()
This member function calls the File I/O function nothing in the FILE-RECORD buffer.  FUNCTION-KEY will be set to 4 (CLOSE-FILE).
BOOL CDataFile::Start()
This member function calls the File I/O function with the internal DataRecord buffer passed to FILE-RECORD.  FUNCTION-KEY will be set to 5 (START-READ).
BOOL CDataFile::Start(char*PrimaryKey)
This member function initializes the beginning of the internal DataRecord with the specified PrimaryKey for KeyLength.  It then calls the File I/O function with the internal DataRecord buffer passed to FILE-RECORD.  FUNCTION-KEY will be set to 5 (START-READ).  Finally, it calls Next(PrimaryKey).
BOOL CDataFile::Restart(BOOL StartFlag)
This member function causes the indexed-sequential file to be restarted on the last-used primary key.  It calls the File I/O routine key FUNCTION-KEY set to 5, calls Next() with the saved primary key, then calls Next() until the saved record is returned into the internal DataRecord.
BOOL CDataFile::Next()
This member function calls the File I/O function with the internal DataRecord buffer passed to FILE-RECORD.  FUNCTION-KEY will be set to 6 (READ-NEXT).
BOOL CDataFile::Next(char*Master)
This member function calls Next().  It then checks the primary key returned against that specified returning TRUE or FALSE depending on the equality.
BOOL CDataFile::Read()
This member function calls the File I/O function with the internal DataRecord buffer passed to FILE-RECORD.  FUNCTION-KEY will be set to 7 (READ-RECORD).
BOOL CDataFile::Read(char*PrimaryKey)
This member function sets the specified primary key into the internal DataRecord and calls Read().
BOOL CDataFile::Add()
This member function calls the File I/O function with the internal DataRecord buffer passed to FILE-RECORD.  FUNCTION-KEY will be set to 8 (ADD-RECORD).
BOOL CDataFile::Update()
This member function calls the File I/O function with the internal DataRecord buffer passed to FILE-RECORD.  FUNCTION-KEY will be set to 9 (UPDATE-RECORD).
BOOL CDataFile::Delete()
This member function calls the File I/O function with the internal DataRecord buffer passed to FILE-RECORD.  FUNCTION-KEY will be set to 10 (DELETE-RECORD).
int CDataFile::DataLength
This variable must be initialized to the length of the internal DataRecord in bytes.
int CDataFile::KeyLength
This variable must be initialized to the length of the primary key at the beginning of the internal DataRecord in bytes.
int CDataFile::MasterLength
This variable must be initialized to the length of the portion of the primary key that defines the "master" or "parent" record's primary key in bytes.
void CDataFile::(*FILEIO)(short*, char*)
This variable must be initialized to the address of the COBOL File I/O routine.
CString CDataFile::HomeDirectory
This variable must be initialized to the path name of the directory that contains the DATA directory that contains the actual data file.


[ CBinaryFile | TCommandLineInfo | CDataFile | TDateCtrl | CDDE | CDdeClient | CDdeServer ]
[ CDirectoryLocator | CDirectoryDialog | CDirectoryFind | CDirectoryNew | CFileCopy | TFrameWnd ]
[ InterfaceExcel | CMaintFn | CPrintFile | CProcDialog | TPrintDialog | CProcPropertyPage ]
[ CProgress | CRegistry | CSDisCreate | CSDisFile | CSDisPage | CSDisView | CTableFile ]
[ CTaskIcon | TPresent | TTime | TDate | TDateTime | CTransferData | TWinApp | CXlTable ]

[ Stand-alone Programs | Standard Library | Conversion Functions | Utility Functions | COBOL Functions ]
[ Windows NT Library | COBOL Library | COBOL Interface | Command Prompt Abbreviations | Purchase Instructions ]

[ Home | Areas of Expertise | "We Do Windows" | Clients and Projects | Software Samples | Package Software Available ]
[ Contact Information | Business Software Philosophy | Church Software Philosophy ]
All contents of this web site are Copyright © Titus Information Systems, Inc., Phoenix, Arizona, U.S.A.