LEGACY COBOL*
SOFTWARE
EXPERTISE ...

KEEPS THE WORLD RUNNING
EVERYDAY ON BILLIONS OF
LINES OF LEGACY CODE



LEGACY COBOL*
SOFTWARE
EXPERTISE


Note: To view the complete COBOL 85 and NEXGEN* code samples (below), it is best to view this on a larger screen.


COBOL 85

The following COBOL code is intended to reasonably reflect how a COBOL-85 program looks (in a side-by-side comparison) with NexGen*Cobol. The comparison is made to illustrate how the NexGen* code is cleaner and leaner without losing any functionality. Some of the standard COBOL keywords and reserved phrases (shown below) have been carried across to NexGen*, but others have been simplified and even dropped where they have been deemed to be unnecessary.

By comparing the two versions of COBOL, it will be relatively easy to identify changes in syntax, especially related to the simplification of COBOL reserved words and phrases. The most noticeable evolution can be found in the shift from the explicit definition of Divisions to a minimalistic keyword-driven program structure. NexGen* uses a much more streamline approach to dividing the functional aspects of Identification, Environment, Data, and Procedure. Another significant change is in the way syntax, in general, is simplified and standardized for mathematical expressions and assignments, as well as for iteration and branching.


*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
*> Creates indexed file from pre-sorted sequential data
*> using 3 keys: record number, currency code, year
*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>


IDENTIFICATION DIVISION.
PROGRAM-ID. IdxDataOptimize_1 IS INITIAL.
AUTHOR. Daniel Turner
DATE-WRITTEN. 2023/08/03 (15:32)

*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT SeqDataFile ASSIGN TO "SX_seqkey_1.dat"
ORGANIZATION IS LINE SEQUENTIAL
FILE STATUS IS InputFileStatus.
SELECT IdxDataFile ASSIGN TO "SX_idx_1.dat"
ORGANIZATION IS INDEXED
ACCESS MODE IS DYNAMIC
RECORD KEY IS RecordKey-I
ALTERNATE RECORD KEY IS CurrencyCode-I
WITH DUPLICATES
ALTERNATE RECORD KEY IS YearOfRate-I
WITH DUPLICATES.

*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

DATA DIVISION.
FILE SECTION.

*> for indexed file
FD IdxDataFile.
01 CurrencyRecordIdx.
02 RecordKey-I PIC 9(4).
02 CurrencyCode-I PIC X(3).
02 YearOfRate-I PIC 9(4).
02 ExchangeRate-I PIC 9(10).

*> for sequential file
FD SeqDataFile.
01 CurrencyRecordSeq PIC X(21).
88 EndOfSeqFile VALUE HIGH-VALUES.

WORKING-STORAGE SECTION.
01 InputFileStatus PIC X(2).
88 RecordFound-S VALUE "00".
01 StopFlag PIC X VALUE "0".
01 RecordCounter PIC 9(4).
01 CounterAlpha PIC X(4).
01 CounterNoZeros PIC ZZZ9.
01 TimeCounter PIC 9(2).
01 TimePercentage PIC X(4).
01 LogTag PIC X(50).
01 MenuOption PIC X.
01 GuidePage PIC X(30).
01 CycleTime PIC 9 VALUE 1.
01 CycleTimeLong PIC 9 VALUE 7.

*> external variable
01 DatabaseSelected PIC X(5) IS EXTERNAL.
01 CrumbStatus PIC X(11) IS EXTERNAL.

*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

PROCEDURE DIVISION.

*> open and verify input file exists
100-OpenFiles.
OPEN INPUT SeqDataFile.
IF (InputFileStatus = "35")
DISPLAY "File Error: (SX_seqkey_1.dat) Not Found"
DISPLAY SPACES
DISPLAY "Press Return To Continue "
WITH NO ADVANCING
ACCEPT StopFlag
DISPLAY SPACES
CLOSE SeqDataFile
GO TO 400-ExitProgram
END-IF.
OPEN OUTPUT IdxDataFile.

*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

*> display menu for optimization options
200-ShowMenu.
DISPLAY SPACES.
DISPLAY "Optimizing Currency Data Records".
DISPLAY "--------------------------------".
DISPLAY "1) Convert Data To Indexed File".
DISPLAY "2) Convert Data To Db2 Database (Not Active)".
DISPLAY SPACES.
DISPLAY "Select Option (0-Exit, 9-User Guide): "
WITH NO ADVANCING.
ACCEPT MenuOption.
DISPLAY SPACES.
IF MenuOption = "1"
GO TO 300-StartIndexing

*> display user guide
ELSE IF MenuOption = "9"
MOVE "UG_DataOptimize_1.dat" TO GuidePage
CALL "UserGuideList_1"
USING BY REFERENCE GuidePage
GO TO 200-ShowMenu

*> exit program
ELSE IF MenuOption = "0"
GO TO 500-CloseFiles

*> invalid entry
ELSE
DISPLAY SPACES
DISPLAY "Invalid Selection"
DISPLAY SPACES
CALL "TimeDelay_1"
USING BY REFERENCE CycleTimeLong
GO TO 200-ShowMenu
END-IF.

*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

*> write records from sequential file to indexed file
300-StartIndexing.
DISPLAY "[Status] Start File Optimization"
MOVE ZEROS TO RecordCounter.

*> reset endoffile
READ SeqDataFile
AT END SET EndOfSeqFile TO TRUE.

*> start file reading/writing
PERFORM UNTIL EndOfSeqFile
WRITE CurrencyRecordIdx FROM CurrencyRecordSeq
INVALID KEY DISPLAY "File Write Error"
END-WRITE
ADD 1 TO RecordCounter
READ SeqDataFile
AT END SET EndOfSeqFile TO TRUE
END-READ
END-PERFORM.

*> time delay loop to display animated progress bar
MOVE 1 TO TimeCounter.
MOVE ". " TO TimePercentage.
PERFORM 3 TIMES
DISPLAY TimePercentage
CALL "TimeDelay_1"
USING BY REFERENCE CycleTimeLong
MOVE "." TO TimePercentage(TimeCounter + 1:1)
ADD 1 TO TimeCounter
END-PERFORM.


*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

*> file processing completed
400-DisplayStatus.
DISPLAY "[Status] Optimization Complete ("
"SX_idx_1.dat)".
CALL "TimeDelay_1"
USING BY REFERENCE CycleTime.
DISPLAY SPACES.
DISPLAY "Record Counter: " RecordCounter.
CALL "TimeDelay_1"
USING BY REFERENCE CycleTimeLong.

*> update log file
MOVE "File Optimization Complete (SX_idx_1.dat)"
TO LogTag.
CALL "LogUpdate_1"
USING BY REFERENCE LogTag.

*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

*> close input and output files
500-CloseFiles.
CLOSE SeqDataFile IdxDataFile.

*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

*> exit program
600-ExitProgram.
MOVE "1" TO CrumbStatus(6:1).
EXIT PROGRAM.

*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>


NEXGEN*COBOL

One of the primary objectives of this new and revolutionary version of COBOL is to allow for a codebase that is more familiar and therefore more attractive to programmers who initially learned to code in modern languages like Python and Java — although this new variant still maintains much of the verb-based syntax that makes COBOL easy to write, debug and maintain. The program below is intentionally simple. In the near future, however, additional examples of NexGen* code will showcase the full set of new keywords and internal functions that supports AI implementation. (see NexGen In-A-Day)

NexGen* is written and compiled based on line-by-line segmentation, which is otherwise linear-format and column-free. The indentations on some lines below are added to provide visual clarity, but they are not necessary. Comments can occupy a single line or can be placed at the end of any statement and are disregarded, as usual, by the compiler. The identification of the four standard COBOL Divisions is dropped from coding requirements, although the concept itself is maintained and easily discerned by keywords and overall program structure.


*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
*> Creates indexed file from pre-sorted sequential data
*> using 3 keys: record number, currency code, year
*> Coded by Daniel Turner [2023/08/03]
*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>


PROGRAM-ID "IdxDataOptimize_1" INITIAL



*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

SET SeqDataFile = "SX_seqkey_1.dat" LINE SEQUENTIAL
STATUS InputFileStatus
SET IdxDataFile = "SX_idx_1.dat" INDEXED DYNAMIC
KEY RecordKey-I
ALTERNATE CurrencyCode-I DUPLICATES
ALTERNATE YearOfRate-I DUPLICATES









*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>




*> for indexed file
FD IdxDataFile
01 CurrencyRecordIdx
02 RecordKey-I 9 (4)
02 CurrencyCode-I X (3)
02 YearOfRate-I 9 (4)
02 ExchangeRate-I 9 (10)

*> for sequential file
FD SeqDataFile
01 CurrencyRecordSeq X (21)
88 EndOfSeqFile IS HIGH

DATA
01 InputFileStatus X (2)
88 RecordFound-S IS "00"
01 StopFlag X (1) IS "0"
01 RecordCounter 9 (4)
01 CounterAlpha X (4)
01 CounterNoZeros ZZZ9
01 TimeCounter 9 (2)
01 TimePercentage X (4)
01 LogTag X (50)
01 MenuOption X (1)
01 GuidePage X (30)
01 CycleTime 9 (1) IS 1
01 CycleTimeLong 9 (1) IS 7

EXTERNAL
01 DatabaseSelected X (5)
01 CrumbStatus X (11)

*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

START

*> open and verify input file exists
SECTION 100-OpenFiles

OPEN INPUT SeqDataFile
IF (InputFileStatus = "35")
DISPLAY:2 "File Error: (SX_seqkey_1.dat) Not Found "
DISPLAY:0 "Press Return To Continue " *> no line feed
ACCEPT:2 StopFlag *> double line feed after ACCEPT
CLOSE SeqDataFile
GO TO 600-ExitProgram
END-IF
OPEN OUTPUT IdxDataFile



*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

*> display menu for optimization options
SECTION 200-ShowMenu

DISPLAY "Optimizing Currency Data Records"
DISPLAY "--------------------------------"
DISPLAY "1) Convert Data To Indexed File"
DISPLAY:2 "2) Convert Data To Db2 Database (Not Active)"
DISPLAY "Select Option (0-Exit, 9-User Guide): "
ACCEPT:2 MenuOption
IF MenuOption = "1"
GO TO 300-StartIndexing

*> display user guide
ELSE IF MenuOption = "9"
SET GuidePage = "UG_DataOptimize_1.dat"
CALL "UserGuideList_1" REFER GuidePage
GO TO 200-ShowMenu

*> exit program
ELSE IF MenuOption = "0"
GO TO 500-CloseFiles

*> invalid entry
ELSE
DISPLAY:2 "Invalid Selection"
CALL "TimeDelay_1" REFER CycleTimeLong
GO TO 200-ShowMenu
END-IF








*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

*> write records from sequential file to indexed file
SECTION 300-StartIndexing

DISPLAY "[Status] Start File Optimization"
SET RecordCounter = 0

*> reset endoffile
READ SeqDataFile AT END SET EndOfSeqFile TO TRUE END-READ

*> start file reading/writing
PERFORM UNTIL EndOfSeqFile
WRITE CurrencyRecordIdx FROM CurrencyRecordSeq
INVALID KEY DISPLAY "File Write Error"
SET RecordCounter = + 1
READ SeqDataFile AT END SET EndOfSeqFile TO TRUE END-READ
END-PERFORM

*> time delay loop to display animated progress bar
SET TimeCounter = 1
SET TimePercentage = ". "
PERFORM (1 TO 3)
DISPLAY TimePercentage
CALL "TimeDelay_1" REFER CycleTimeLong
SET TimePercentage(TimeCounter + 1:1) = "."
SET TimeCounter = + 1 *> adds 1 to TimeCounter
END-PERFORM






*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

*> file processing completed
SECTION 400-DisplayStatus

DISPLAY:2 "[Status] Optimization Complete (SX_idx_1.dat)"
CALL "TimeDelay_1" REFER CycleTime
DISPLAY "Record Counter: " RecordCounter
CALL "TimeDelay_1" REFER CycleTimeLong

*> update log file
SET LogTag = "File Optimization Complete (SX_idx_1.dat)"
CALL "LogUpdate_1" REFER LogTag






*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

*> close input and output files
SECTION 500-CloseFiles
CLOSE SeqDataFile IdxDataFile

*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

*> exit program
SECTION 600-ExitProgram
SET CrumbStatus(6:1) = "1"
EXIT

*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>








1999- ©  Daniel Turner  All Rights Reserved



 1999- ©  Daniel Turner
  All Rights Reserved