Titus Information Systems, Inc.

Standard Library
COBOL Interface

These routines mainly provide an interface from C++ to the COBOL Library.  They also provide additional functionality to COBOL programs.  Following are the descriptions of these routines:

DATE$O – Date Calculation
This routine performs date calculations.  It was designed to be called from any language; it has been thoroughly tested with the MicroFocus NetExpress COBOL compiler.  It is called with four arguments.  The first argument is short*Key, a PIC S9999 USAGE COMP-5 passed by reference.  Key determines the format of the remaining three arguments, char*DateOne, char*DateTwo, and long*Result.  This routine uses a four-byte date storage method known as CYMD, where the date is stored in four parts, one byte each, consisting of the century, the year in the century, the month, and the day.  For example, May 19, 2003 would be stored in four bytes with the values 20, 3, 5, and 19.  The following calculations are performed depending on the value of Key:
Key = 1 – Return difference in days between DateOne (CYMD) and DateTwo (CYMD) in Result (long)
Key = 2 – Convert DateOne (CYMD) to absolute Julian in Result (long)
Key = 3 – Convert DateOne (CYMD) to DateTwo (MM/DD/YY) and Result (MONTH DY, YEAR)
Key = 4 – Convert DateOne (Year:short/Julian:short) to DateTwo (CYMD)
Key = 5 – Convert DateOne (MM/DD/YY) to DateTwo (CYMD) and absolute julian in Result (long)
Key = 6 – Return current date in DateOne (MM/DD/YY), DateTwo (CYMD), and Result (MONTH DY, YEAR)
Key = 7 – Do DATEDF calculation (see routine for description)
Key = 8 – Do DATEGN calculation (see routine for description)
Key = 9 – Convert DateOne (YYYYMMDD) to DateTwo (CYMD) and absolute julian in Result (long)
Key = 10 – Convert absolute julian in Result (long) to DateOne (YYYYMMDD) and DateTwo (CYMD)
Key = 11 – Convert DateTwo (CYMD) to DateOne (YYYYMMDD) and absolute julian in Result (long)
Key = 12 – Return age (years) from DateOne (CYMD) in Result (long)
Key = 13 – Convert DateOne (YYYY-MM-DD) to DateTwo (CYMD) and absolute julian in Result (long)
Key = 14 – Convert DateOne (CYMD) to DateTwo (MM/DD/YY) and Result (DY MONTH, YEAR)
Key = 15 – Return current date in DateOne (MM/DD/YY), DateTwo (CYMD), and Result (DY MONTH, YEAR)
Key = 16 – Compute end of month from DateOne (CYMD) into DateTwo (CYMD) and absolute julian in Result (long)
Key = 17 – Return age (years) between DateOne (CYMD) and DateTwo (CYMD) in Result (long)
Key = 18 – Convert DateOne (MM/DD/YYYY) to DateTwo (CYMD) and absolute julian in Result (long)
Key = 19 – Convert DateOne (CYMD) to DateTwo (MM/DD/YYYY) and Result (MONTH DY, YEAR)
Key = 20 – Convert DateOne (CYMD) to DateTwo (MM/DD/YYYY) and Result (DY MONTH, YEAR)
Key = 21 – Return current date in DateOne (MM/DD/YYYY), DateTwo (CYMD), and Result (MONTH DY, YEAR)
Key = 22 – Return current date in DateOne (MM/DD/YYYY), DateTwo (CYMD), and Result (DY MONTH, YEAR)
Key = 23 – Convert DateOne (TDateCtrl) to DateTwo (CYMD) and absolute julian in Result (long)
Key = 24 – Convert DateTwo (CYMD) to DateOne (TDateCtrl) and absolute julian in Result (long)
DATEDF – Calculate Date Difference
This program calculates the number of days, weeks, and months between the two given dates.  The one argument is the following array.  BEGIN-DATE and END-DATE must be specified by the calling program.  The remaining fields are calculated by this routine.  The four RESULT fields are the count for each.  BEGIN-WEEK-DAY and END-WEEK-DAY are 1 = Sunday through 7 = Saturday.
        01  DATE-CALCULATION.
            03  BEGIN-DATE.
                05  BD-CENT    PIC S99 USAGE COMP-5.
                05  BD-YEAR    PIC S99 USAGE COMP-5.
                05  BD-MNTH    PIC S99 USAGE COMP-5.
                05  BD-DAY     PIC S99 USAGE COMP-5.
            03  END-DATE.
                05  ED-CENT    PIC S99 USAGE COMP-5.
                05  ED-YEAR    PIC S99 USAGE COMP-5.
                05  ED-MNTH    PIC S99 USAGE COMP-5.
                05  ED-DAY     PIC S99 USAGE COMP-5.
            03  RESULT-DAYS    PIC S9999 USAGE COMP-5.
            03  RESULT-WEEKS   PIC S9999 USAGE COMP-5 OCCURS 7 TIMES.
            03  RESULT-MONTHS  PIC S9999 USAGE COMP-5.
            03  RESULT-YEARS   PIC S9999 USAGE COMP-5.
            03  BEGIN-WEEK-DAY PIC S9999 USAGE COMP-5.
            03  END-WEEK-DAY   PIC S9999 USAGE COMP-5.
DATEGN – Generate Dates
This program calculates the dates for the day of the week specified for each week of the specified quarter.  The one argument is the following array.  GENERATED-DATE(1) must be specified as the first date of the weekday in the quarter by the calling program.  The remaining (up to) fourteen dates are generated by this routine.
        01  DATE-GENERATION.
            03  GENERATED-DATE OCCURS 15 TIMES.
                05  GD-CENT    PIC S99 USAGE COMP-5.
                05  GD-YEAR    PIC S99 USAGE COMP-5.
                05  GD-MNTH    PIC S99 USAGE COMP-5.
                05  GD-DAY     PIC S99 USAGE COMP-5.
LEAPYR – Leap Year
This routine returns one for leap year, zero for non-leap year.  It is called with one argument, the four-digit year as PIC S9999 USAGE COMP-5 or (short*).  The function returns a (short).
WKDAY – Week Day
This routine returns the day of the week: 1 = Sunday through 7 = Saturday.  It is called with one argument as (char*), the date in CYMD format.  The function returns a (short).
TListBox – Display File List Box
Inherited from CListBox, this class puts long file names from the specified directory in the list box managed by the base class.  It has one member function:

int TListBox::Directory(UINT Attribute, LPCTSTR FileName)

FileName specifies the path of the directory, including any wild cards desired.  Attribute specifies the attributes of the files that will be listed.  Only FILE_ATTRIBUTE_DIRECTORY, FILE_ATTRIBUTE_HIDDEN, FILE_ATTRIBUTE_READONLY, and FILE_ATTRIBUTE_SYSTEM are observed, but more than one of these attributes may be specified.  The value of the function is the number of entries in the ListBox control when the function completes.
BOOL ValidateNonZero(CString Number)
This routine checks a numeric field, PIC 9(n), for zero.  If all digits are zero, the function returns FALSE.  If any digits are non-zero, the function returns TRUE.
BOOL ValidateDirection(CString Direction, CString&Description)
This routine validates a street direction using the COBOL Library function VALDIREC.  If Direction is valid, the function returns TRUE and Description will contain the description of the direction.  Otherwise, the function returns FALSE.
short ValidateState(CString State, CString&Description)
This routine validates a U.S.A. Postal Service state abbreviation code using the COBOL Library function VALSTATE.  If State is valid, the function returns the state index and Description will contain the name of the state.  Otherwise, the function returns -1.
char*ReturnStateCode(int Index)
This routine returns a U.S.A. Postal Service state abbreviation code for the state index returned by the COBOL Library function VALSTATE or the ValidateState function described above.  The returned string will be two characters long and will be null-terminated (for a total of three characters).
BOOL ValidateTelephone(CString Telephone, int Length)
This function validates the telephone number in Telephone which must be in display format based on Length.  Length may be 7, 10, 14.  When 7, the input string must be in the format "nnn-nnnn".  When 10, the input string must be in the format "(nnn) nnn-nnnn".  When 14, the input string must be in the format "(nnn) nnn-nnnn X nnnn".  If the format of Telephone is valid, the function returns TRUE.  Otherwise, the function returns FALSE.
BOOL ValidatePrintOption(CString PrintOption, CString&Description)
This routine validates a print option using the COBOL Library function VALPROPT.  If PrintOption is valid, the function returns TRUE and Description will contain the description of the print option.  Otherwise, the function returns FALSE.


[ Stand-alone Programs | Standard Library | Conversion Functions | Utility Functions | COBOL Functions ]
[ Windows NT Library | COBOL Library | 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.