sams_teach_yourself_cobol_in_24_hours_-_hour_10_processing_loops

Sams Teach Yourself COBOL in 24 Hours - Hour 10 Processing Loops

Return to Teach Yourself COBOL in 24 Hours, COBOL bibliography, COBOL, COBOL DevOps, Awesome COBOL, Awesome IBM Mainframe, IBM Mainframe development, IBM Mainframe bibliography, Fortran

“ (TYCb24H 1998)

Hour 10 Processing Loops

The utility of computer programs is derived from their capability to perform repetitive tasks accurately and quickly. To do so, a programmer codes a processing loop. A processing loop is simply something in your program that happens over and over. The word loop comes from what it looks like in a flowchart. The flow of your program keeps looping repeatedly until some specified condition is reached. In this hour, you learn the basic steps you need to create processing loops in COBOL. The following topics are discussed:

• The Perform statement

• COBOL Sections and Paragraphs

• Program flow in the Procedure Division

• The use of Go To in structured programming design

Figure 10.1 shows a simple processing loop. You can follow the arrows for the direction of flow through the program. The diamond is a decision box. If the answer to the question it asks is yes, the loop is finished and the program stops. However, if the answer is no, then the loop is not finished and the program repeats the computing process.

A typical computer program will start, perform some function or functions until a specified condition is encountered, then stop.

Figure 10.1 Flowchart of a processing loop.

Image

The Basic Perform Statement One way to create a processing loop with COBOL is to use a Perform statement. The Perform statement executes the code you specify after the Perform and then returns in your program to the point immediately after the Perform statement.

The simplest format of the Perform statement allows you to Perform a Section or Paragraph within the Procedure Division of your program.

000020 Procedure Division. 000021 Start-Of-Program. 000022 Perform Paragraph-1 000023 Display “Return From Paragraph 1” 000024 Stop Run 000025 . 000026 Paragraph-1. 000027 Display “Paragraph 1” 000028 Display “End of Paragraph 1” 000029 . The Procedure Division from this example Displays “Paragraph 1” and then “End of Paragraph 1” followed by “Return from Paragraph 1”. The Perform statement jumps to Paragraph-1, executes the statements in the Paragraph, and then jumps back to the point in the program immediately following the Perform.

Sections and Paragraphs Remember that in COBOL you can divide the Procedure Division into Sections, using Section headings. The examples thus far have not used Sections. The COBOL standard states that a Paragraph title should follow any Section headings. Most compilers ignore this rule and allow you to insert programming statements immediately following Section headings. These lessons are coded according to the standard and use Paragraph titles after Section headings.

A Section can have many Paragraphs. When you Perform a Section, all the Paragraphs in the Section are performed from the top down. At the start of the next Section, the program returns to the next line after the Perform of that Section. This practice is not often used and is not recommended. It is not obvious when you read the Perform statement that multiple Paragraphs are going to be executed.

If a Paragraph in a Section is performed, then the program returns to the statement immediately after the Perform when the next Paragraph or Section is encountered. The example from Listing 10.1 should clarify this sequence of events.

Listing 10.1 Perform Example

000001 @OPTIONS MAIN 000002 Identification Division. 000003 Program-Id. Chapt10a. 000004* Perform Example 000005 Environment Division. 000006 Configuration Section. 000007 Source-Computer. IBM-PC. 000008 Object-Computer. IBM-PC. 000009 Data Division. 000010 Working-Storage Section. 000011 Procedure Division. 000012 Chapt10a-Section Section. 000013 Chapt10a-Start. 000014 Perform First-Section 000015 Perform Para-2 000016 Stop Run 000017 . 000018 First-Section Section. 000019 Para-1. 000020 Display “Para 1” 000021 . 000022 Para-2. 000023 Display “Para 2” 000024 . 000025 Para-3. 000026 Display “Para 3” 000027 . As you can see from the output as shown in Figure 10.2, the first Perform causes each statement in the entire Section to be executed. The second Perform executes only the statement under Para-2.

Figure 10.2 Output from Listing 10.1

Image

Aside from performing a Section or a Paragraph, you may Perform a range of Paragraphs. To do so, state the starting Paragraph, the word Thru (or Through), and the last Paragraph to be executed. Each Paragraph between the two Paragraph titles specified is executed, and all statements under the last Paragraph are executed. For example, to execute Para-1 and Para-2 in the example, you may code the following:

000063 Perform Para-1 Thru Para-2 The program Displays “Para-1” followed by “Para-2”.

Image

The Perform with the Thru clause has been widely used for years. However, the advances in the COBOL language that were included in the 1985 standard have made its use unnecessary. As you will see in the next section, the Perform with Thru is often used when a Go To is used to control the processing loop. No exercises in this book require the use of Perform with Thru. I am presenting it because I am sure that if you do pursue a career in COBOL, you will see it in use, and you should understand it.

When using Perform with the Thru clause, many programmers code a dummy Paragraph after the end of the Paragraph. The dummy Paragraph contains only the word Exit. Exit does nothing and is coded only because each Paragraph has to contain at least one statement.

000060 Perform Para-1 Thru Para-1-Exit 000061 Stop Run 000062 . 000063 Para-1. 000064 Display “Para 1” 000065 . 000066 Para-1-Exit. 000067 Exit. This example performs both Para-1 and Para-1-Exit, but it looks as though only Para-1 is being performed because Para-1-Exit has no processing statements. It is important to remember that when Thru is used with a Perform, all statements in the Thru Paragraph are performed.

Creating Processing Loops Using Perform You are probably asking yourself how Perform relates to processing loops. If Perform executes a Paragraph only once, how can it be used to create a loop?

With Perform, you can Perform a Paragraph multiple times. For example, if you want to count to 10, you can Perform a counting Paragraph 10 times.

000078 Move Zeros To Num-Counter 000079 Perform Count-By-1 10 Times 000080 Stop Run 000081 . 000082 Count-By-1. 000083 Add 1 To Num-Counter 000084 Display Num-Counter 000085 . This Procedure Division code Performs the Count-By-1 Paragraph 10 times. The program does not return to the statement after the Perform until the Perform is executed 10 times.

Image

The Stop Run that is coded after the Perform is very important. If you did not have it, the flow of the program would fall through the Count-By-1 Paragraph and execute it yet again.

The number of times a Perform is to be executed can be specified by a numeric data item or a numeric literal.

In addition to performing a Paragraph a certain number of times, you can base a Perform on a conditional test. You do this by using Until. With Until you tell the program to Perform the Paragraph, testing for your condition before every execution of the Paragraph, Until the condition is true. All statements under the Paragraph are executed. The test for your condition occurs before the Paragraph is next executed. If your condition is true, the Paragraph is not executed.

The program in Listing 10.2 uses Perform with Until to control the processing. This program is a modification of the program used in Hour 6, “Manipulating Data,” to split up the name and change the email address to lowercase. Listing 10.2 continues to Accept new input Until the user presses the F1 key.

Listing 10.2 Name And Email Edit Processing Loop

000001 @OPTIONS MAIN 000002 Identification Division. 000003 Program-Id. Chapt10c. 000004* Name And E-Mail Edit - Processing Loop. 000005 Environment Division. 000006 Configuration Section. 000007 Special-Names. 000008 Crt Status Is Keyboard-Status. 000009 Source-Computer. IBM-PC. 000010 Object-Computer. IBM-PC. 000011 Data Division. 000012 Working-Storage Section. 000013 01 Keyboard-Status. 000014 03 Accept-Status Pic 9. 000015 03 Function-Key Pic X. 000016 88 F1-Pressed Value X”01”. 000017 03 System-Use Pic X. 000018 01 Screen-Items. 000019 03 Name-Entry Pic X(40) Value Spaces. 000020 03 E-Mail Pic X(30) Value Spaces. 000021 03 Output-Fields. 000022 05 Last-Name Pic X(30) Value Spaces. 000023 05 First-Name Pic X(30) Value Spaces. 000024 05 Error-Message Pic X(60) Value Spaces. 000025 01 Work-Numbers. 000026 03 Work-Number Pic 99 Value Zeros. 000027 03 Work-Number-1 Pic 99 Value Zeros. 000028 03 Work-Number-2 Pic 99 Value Zeros. 000029 Screen Section. 000030 01 Name-Entry-Screen 000031 Blank Screen, Auto 000032 Foreground-Color Is 7, 000033 Background-Color Is 1. 000034* 000035 03 Screen-Literal-Group. 000036 05 Line 01 Column 30 Value “Name and E-mail Entry” 000037 Highlight Foreground-Color 4 Background-Color 1. 000038 05 Line 05 Column 05 Value “ Name: ”. 000039 05 Line 06 Column 05 Value “E-mail: ”. 000040 05 Line 08 Column 05 Value “ Last: ”. 000041 05 Line 09 Column 05 Value “ First: ”. 000042 05 Line 22 Column 05 Value “Press F1 to Exit”. 000043 03 Reverse-Video-Group Reverse-Video. 000044 05 Line 05 Column 13 Pic X(40) Using Name-Entry. 000045 05 Line 06 Column 13 Pic X(30) Using E-Mail. 000046 05 Line 08 Column 13 Pic X(30) From Last-Name. 000047 05 Line 09 Column 13 Pic X(30) From First-Name. 000048 05 Line 20 Column 01 Pic X(60) 000049 Highlight From Error-Message. 000050 Procedure Division. 000051 Chapt10c-Start. 000052 Perform Display-And-Accept-Screen Until F1-Pressed 000053 Stop Run 000054 . 000055 Display-And-Accept-Screen. 000056 Display Name-Entry-Screen 000057 Accept Name-Entry-Screen 000058* Reset The Working Fields 000059 Initialize Output-Fields 000060 Work-Numbers 000061* Make Sure There Is A Comma In The Name 000062 Inspect Name-Entry Tallying Work-Number-2 For All “,” 000063* Only Try To Split If There Is One 000064 If Work-Number-2 > Zeros 000065 Perform Process-The-Data 000066 Else 000067 Move “Name must contain a comma” To Error-Message 000068 End-If 000069 . 000070 Process-The-Data. 000071* Split The First And Last Name Out Into Separate Fields 000072 Inspect Name-Entry Tallying Work-Number 000073 For Characters Before “,” 000074 Move Name-Entry (1:work-Number) To Last-Name 000075 Add 2 To Work-Number 000076* We Need To Exclude The Leading Spaces, After The Comma 000077 Inspect Name-Entry (Work-Number:) 000078 Tallying Work-Number-1 For Leading Spaces 000079 Move Name-Entry (Work-Number + Work-Number-1:) To First-Name 000080* Change The E-Mail Address To All Lower Case Letters. 000081 Inspect E-Mail Converting “ABCDEFGHIJKLMNOPQRSTUVWXYZ” 000082 To “abcdefghijklmnopqrstuvwxyz” 000083 . The first item to examine in this program is the addition of the Special-Names Paragraph. As you learned in Hour 4, “Basic User Interface,” in relation to the Screen Section, the Special-Names Paragraph captures the function key pressed by the user. A conditional (88 level) item corresponds to the value in the field when F1 is pressed.

An error message line has been added to the screen. This message appears if the user does not enter a comma in the name field. A new numeric data item was added in which to accumulate the number of commas in the Name-Entry, using the Inspect statement. If no commas occur, an error message is displayed and the input fields are not processed.

The working fields are initialized between every execution of the logic to split the name. You don’t need the headache of having any leftover values in these fields. The initialization of these fields is simplified by grouping them and using an Initialize statement against the two groups.

Notice the use of the Perform with Until. This Perform continues to be executed Until the F1 key is pressed. The second Perform is coded as part of an If statement. You may code a Perform anywhere you would normally code any other COBOL statement.

Take note of the general program structure. This style of coding is called structured programming. The program uses what is sometimes referred to as a top-down design. Top-down design takes the highest level and gradually breaks down each function into smaller and smaller parts until you have simple programming statements.

The main Paragraph shows the logic of the program. It is to display and accept a screen Until the user presses F1 and then terminate. Using the 88 level for the F1 key makes the program self-documenting. Liberal use of comments helps to clarify the action.

Within the processing Paragraph, you can easily discern what is happening in the program. There is no jumping around. The only condition that is tested is the one used to validate the input and determine whether the field should be processed. If so, that single Paragraph is executed. Its sole function is to process the input data.

This example uses an 88 level item to determine the termination of the performed Paragraph. Any condition may be coded with the Perform to control the processing loop. You must remember that the condition that is specified in the Perform statement is tested before the Perform is executed. If the condition is true upon the first pass, your Perform is never executed. Look at this example:

000086 Move “A” to Test-Item 000087 Perform Para-1 Until Test-Item = “A” 000088 Stop Run 000089 . 000090 Para-1. 000092 If Data-A + Data-B = 25 000093 Move “A” to Test-Item 000094 End-If 000095 . In this example, Para-1 is never executed. (Remember that the test of the condition occurs before the Paragraph is executed.) It seems obvious when you look at the code, but once the program is compiled the computer does not really know how many times processing has passed through this Perform. The tests are always the same, whether this is the first execution or the one-millionth.

Use of Go To COBOL, like most other programming languages, has a Go To statement. The Go To causes the program to jump to the Paragraph title or Section header specified in the Go To statement. As with Perform … Thru, the advances in the COBOL language with the 1985 standard have eliminated any need to use Go To. However, it seems to be the “easy way out” for many programmers, and I think it is worthwhile to spend some time explaining its use and abuse.

Go To causes what is referred to as an unconditional branch. The logic of your program jumps to the point of the Go To and does not return, in contrast to the logic of a Perform. What follows is an example of a processing loop using Go To.

000096 Start-Of-Loop. 000097 If Data-A + Data-B not = 25 000098 Go To Start-Of-Loop 000099 End-If 000100 Stop Run 000101 . This code seems simple enough. The loop continues until Data-A + Data-B is equal to 25. In its simplest form, Go To doesn’t appear to be so bad; however, when mixed with more Go To statements, multiple Paragraphs, and Perform statements, your program soon becomes unreadable and hard to follow.

In order to demonstrate the differences between using Go To and Perform, consider this programming problem. You need a processing loop to Accept a screen of data. The screen has three fields: First Name, Last Name, and E-mail Address. For each field, check to see whether an entry was made. If entered, convert the first and last names to uppercase. If the email address was entered, convert it to lowercase. If the fields are blank, replace them with asterisks. Both approaches are shown in Chapt10d.Cob, as shown in Listing 10.3.

The first part of the program is the same for both approaches. The differences begin in the Procedure Division.

Listing 10.3 Go To Versus Perform Logic

000001 @OPTIONS MAIN 000002 Identification Division. 000003 Program-Id. Chapt10d. 000004* Go To Vs Perform Logic 000005 Environment Division. 000006 Configuration Section. 000007 Special-Names. 000008 Crt Status Is Keyboard-Status. 000009 Source-Computer. IBM-PC. 000010 Object-Computer. IBM-PC. 000011 Data Division. 000012 Working-Storage Section. 000013 01 Keyboard-Status. 000014 03 Accept-Status Pic 9. 000015 03 Function-key Pic X. 000016 88 F1-Pressed Value X”01”. 000017 03 System-Use Pic X. 000018 01 Screen-Items. 000019 03 Last-Name Pic X(20) Value Spaces. 000020 03 First-Name Pic X(20) Value Spaces. 000021 03 E-mail Pic X(30) Value Spaces. 000022 Screen Section. 000023 01 Entry-Screen 000024 Blank Screen, Auto 000025 Foreground-Color Is 7, 000026 Background-Color Is 1. 000027* 000028 03 Screen-Literal-Group. 000029 05 Line 01 Column 30 Value “Name and E-mail Entry” 000030 Highlight Foreground-Color 4 Background-Color 1. 000031 05 Line 06 Column 05 Value “E-mail: ”. 000032 05 Line 08 Column 05 Value “ Last: ”. 000033 05 Line 09 Column 05 Value “ First: ”. 000034 05 Line 22 Column 05 Value “Press F1 to Exit”. 000035 03 Reverse-Video-Group Reverse-Video. 000036 05 Line 06 Column 13 Pic X(30) Using E-mail. 000037 05 Line 08 Column 13 Pic X(20) Using Last-Name. 000038 05 Line 09 Column 13 Pic X(20) Using First-Name. 000039 Procedure Division. 000040 Chapt10d-Start. For the Perform version, the main processing loop can be stated in one simple statement:

Perform Display-And-Accept-Screen Until F1-Pressed Now the next level down in the top-down design is coded. This is the Display-And-Accept-Screen Paragraph.

000041 Display-And-Accept-Screen. 000042 Display Entry-Screen 000043 Accept Entry-Screen 000044 If F1-Pressed 000045 Continue 000046 Else 000047 Perform Process-Data-Fields 000048 End-If 000049 . This Paragraph displays and then accepts the entry screen. The If following the Accept checks for the F1 key. If it was pressed, the data fields are not processed; however, if it was not pressed, the data fields are processed.

The processing of the data fields is coded simply. Each field is checked to see whether it was entered. If so, the conversion is performed. If not, asterisks are placed in the field.

000050 Process-Data-Fields. 000051 If Last-Name > Spaces 000052 Perform Process-Last-Name 000053 Else 000054 Move “********************” To Last-Name 000055 End-If 000056 If First-Name > Spaces 000057 Perform Process-First-Name 000058 Else 000059 Move “********************” to First-Name 000060 End-If 000061 If E-Mail > Spaces 000062 Perform Process-E-Mail 000063 Else 000064 Move “******************************” to E-Mail 000065 End-If 000066 . As each field is checked, any data that was entered into the field is processed in the appropriate Paragraph.

000067 Process-Last-Name. 000068 Inspect Last-Name Converting “abcdefghijklmnopqrstuvwxyz” 000069 To “ABCDEFGHIJKLMNOPQRSTUVWXYZ” 000070 . 000071 Process-First-Name. 000072 Inspect First-Name Converting “abcdefghijklmnopqrstuvwxyz” 000073 To “ABCDEFGHIJKLMNOPQRSTUVWXYZ” 000074 . 000075 Process-E-Mail. 000076 Inspect E-Mail Converting “ABCDEFGHIJKLMNOPQRSTUVWXYZ” 000077 To “abcdefghijklmnopqrstuvwzyz” 000078 . Each Paragraph handles conversion of each associated field. Much more could be happening in these Paragraphs, but this example is just for demonstration. Normally, you would not code a Perform with only a single statement under it.

This program is easy to follow. Each Paragraph performs a function and returns. The program was easy to design. Each step was broken down into smaller steps until the program was written. This method is top-down, structured programming.

One interesting feature of this style is that you can rearrange the Paragraphs in any order you desire. For example, you can put the Process-E-Mail Paragraph before the Process-Last-Name Paragraph, and everything will function properly. The program will never fall through a Paragraph name.

Now examine the code and process necessary to produce the same results using the Go To statement.

000079 Process-Screen. 000080 Display Entry-Screen 000081 Accept Entry-screen 000082 If F1-Pressed 000083 Stop Run 000084 End-If 000085 If Last-Name > Spaces 000086 Go To Process-Last-Name-Goto 000087 Else 000088 Move “********************” to Last-Name 000089 End-If 000090 . Notice lines 82 and 83; the Stop Run statement is coded so that if the user presses the F1 key, the program stops immediately and does not continue to process. Next, the last name is checked. If it is entered, the Go To Paragraph processes the last name. If it is not entered, asterisks are moved into the field.

The logic flow of the program falls through the next Paragraph. The only reason for a Paragraph name is that after the last name is processed, a label is required as a return point so that the program can continue to process the screen.

000091 Check-First-Name. 000092 If First-Name > Spaces 000093 Go To Process-First-Name-Goto 000094 Else 000095 Move “********************” To First-Name 000096 End-If 000097 . 000098 Check-E-Mail. 000099 If E-Mail > Spaces 000100 Go To Process-E-Mail-Goto 000101 Else 000102 Move “******************************” to E-mail 000103 End-If 000104 Go To Process-Screen 000105 . These two Paragraphs determine whether the first name and email need to be processed. Again, the Check-E-Mail Paragraph is coded so that there is a place to return to from an earlier Go To.

The process Paragraphs are coded as follows:

000106 Process-Last-Name-Goto. 000107 Inspect Last-Name Converting “abcdefghijklmnopqrstuvwxyz” 000108 To “ABCDEFGHIJKLMNOPQRSTUVWXYZ” 000100 Go To Check-First-Name 000110 . 000111 Process-First-Name-Goto. 000112 Inspect First-Name Converting “abcdefghijklmnopqrstuvwxyz” 000113 To “ABCDEFGHIJKLMNOPQRSTUVWXYZ” 000114 Go To Check-E-Mail 000115 . 000116 Process-E-Mail-Goto. 000117 Inspect E-Mail Converting “ABCDEFGHIJKLMNOPQRSTUVWXYZ” 000118 To “abcdefghijklmnopqrstuvwzyz” 000119 Go To Process-Screen 000120 . Notice in the first Paragraph, the logic jumps back to Check-First-Name. In the second, the logic jumps back to Check-E-Mail, and in the third it goes back to the main screen process. See how hard this logic is to follow? It is also easy to really mess up later. You have to be aware that you are falling through the Paragraph titles. If you forget, or don’t realize it, you can corrupt the logic of the program by moving a Paragraph or by inserting a new Paragraph or Go To.

What if you want to add a fourth field? With the Perform method, you it can simply add one more If statement in the Process-Data-Fields Paragraph and then code that process Paragraph by itself. Contrast this approach with the modifications needed in the Go To example.

First, you have to change the Process-E-Mail-Go To Paragraph to not Go To Process-Screen, but instead to go back to your new Paragraph. Your new Paragraph would assume the role of going back to the Process-Screen Paragraph. In addition, you have to change the Check-E-Mail Paragraph so that it does not go back to Process-Screen and, instead, falls through another new Paragraph. This new Paragraph would go back to Process-Screen.

What if, for some reason, you wanted this new field to be processed first? Nearly every Paragraph would require a change. With the Perform version, all you have to do is position the new If statement in the proper place in the Process-Data-Fields Paragraph.

Listing 10.4 shows what happens when you mix Go To with Perform logic.

Listing 10.4 Perform With Go To Example

000001 @OPTIONS MAIN 000002 Identification Division. 000003 Program-Id. Chapt10e. 000004* Perform With Go To Example 000005 Environment Division. 000006 Configuration Section. 000007 Source-Computer. IBM-PC. 000008 Object-Computer. IBM-PC. 000009 Data Division. 000010 Working-Storage Section. 000011 Procedure Division. 000012 Chapt10a-Section Section. 000013 Chapt10a-Start. 000014 Perform Para-2 000015 Stop Run 000016 . 000017 First-Section Section. 000018 Para-1. 000019 Display “Para 1” 000020 . 000021 Para-2. 000022 Display “Para 2” 000023 Go To Para-1 000024 . 000025 Para-3. 000026 Display “Para 3” 000027 . Try to follow the logic and see what you think this program should do. It appears as if the program will Display “Para 2”, then “Para 1”, and then stop. That’s not what happens. The Perform of Para-2 is not going to stop until it encounters the next Paragraph title, which is Para-3. The Go To prevents this from happening. This program executes an infinite, or endless, loop. After the Go To, Para-1 is executed. Then the program falls through the Para-2 label and continues. It then hits the Go To and goes back to Para-1 yet again. If you run the program, you will see endless displays of “Para 1” and “Para 2”. You can stop the program by right-clicking the toolbar on the Chapt10e program item and choosing Close.

I strongly suggest that you use the structured approach introduced by this book for your programs. Do not use Go To. Keeping your programming structured leads to programs that are easy to design, follow, and understand.

Summary In this hour, you learned the following:

• A processing loop repeats a task until some specified condition is reached.

• The Perform statement can execute a Paragraph or Section and then return to the point in the program immediately after the Perform.

• Perform can execute a Paragraph once, a specified number of times, or until a condition is satisfied.

• By performing a Section, you can fall through multiple Paragraphs, even though this approach is not recommended.

• By using Thru, you can Perform a range of Paragraphs.

• The difference between structured and non-structured programming.

• How mixing structured and non-structured programming can lead to problems.

• Why Go To causes your programs to be non-structured and should be avoided.

Q&A Q I don’t quite understand the term processing loop. Can you explain it?

A A processing loop tells the computer to execute, or Perform, a process multiple times. The loop is repeated until some specified condition occurs. Think of it like a race. The cars go round and round until the checkered flag is thrown. The race track is the loop, and the checkered flag is the condition that causes the loop to end.

Q When I Perform an individual Paragraph within a Section, when does the Perform stop and return?

A The Perform terminates when the next Paragraph title, also called a label or heading, is encountered. The Perform also ends if another Section is encountered.

Q Besides grouping Paragraphs, is there another purpose for Sections? They seem unnecessary to me.

A For most of your programming, Sections are unnecessary. Some earlier versions of COBOL required Sections under certain circumstances, but modern COBOL doesn’t have that restriction. Sections can also be coded with Section numbers. They follow the word Section and cause the compiler to group like numbered Sections into overlays. Some compilers had limits to the size of a program, and you needed to divide your code into Sections that could be loaded and unloaded as memory became available. These overlays were the original purpose for defining Sections as part of the COBOL language. The behavior of Paragraphs within Sections is largely a byproduct of the actual behavior of overlays. With modern compilers, the use of overlays and Sections is no longer an issue.

Q Are you serious when you say I should avoid using Go To? Can’t I just use it when it’s really convenient?

A Yes, I am serious. You should not use Go To. With structured programming, Go To is entirely unnecessary. If you find yourself tempted to use it, you might want to reconsider the design of your program. Some programmers use Go To statements sparingly to jump either to the start or end of a Paragraph or Section. Even this use is unnecessary. However, if you end up programming for a living, you will probably encounter COBOL code that looks like spaghetti when you try to follow the logic because of all of the Go To usage. You need to know how to maintain that code, and trying to turn spaghetti code into structured code is not an easy task. For the most part, when you are maintaining someone else’s program, you are best advised to follow the style he or she used.

Workshop To help reinforce your understanding of the material presented in this hour, refer to the section “Quiz and Exercise Questions and Answers” that can be found on the CD. This section contains quiz questions and exercises for you to complete, as well as the corresponding answers.

Fair Use Sources

COBOL: COBOL Fundamentals, COBOL Inventor - COBOL Language Designer: 1959 by Howard Bromberg, Norman Discount, Vernon Reeves, Jean E. Sammet, William Selden, Gertrude Tierney, with indirect influence from Grace Hopper, CODASYL, ANSI COBOL, ISO/IEC COBOL; Modern COBOL - Legacy COBOL, IBM COBOL, COBOL keywords, COBOL data structures - COBOL algorithms, COBOL syntax, Visual COBOL, COBOL on Windows, COBOL on Linux, COBOL on UNIX, COBOL on macOS, Mainframe COBOL, IBM i COBOL, IBM Mainframe DevOps, COBOL Standards, COBOL Paradigms (Imperative COBOL, Procedural COBOL, Object-Oriented COBOL - COBOL OOP, Functional COBOL), COBOL syntax, COBOL installation, COBOL containerization, COBOL configuration, COBOL compilers, COBOL IDEs, COBOL development tools, COBOL DevOps - COBOL SRE, COBOL data science - COBOL DataOps, COBOL machine learning, COBOL deep learning, COBOL concurrency, COBOL history, COBOL bibliography, COBOL glossary, COBOL topics, COBOL courses, COBOL Standard Library, COBOL libraries, COBOL frameworks, COBOL research, Grace Hopper, COBOL GitHub, Written in COBOL, COBOL popularity, COBOL Awesome list, COBOL Versions. (navbar_cobol)


Cloud Monk is Retired (for now). Buddha with you. © 2005 - 2024 Losang Jinpa or Fair Use. Disclaimers

SYI LU SENG E MU CHYWE YE. NAN. WEI LA YE. WEI LA YE. SA WA HE.


sams_teach_yourself_cobol_in_24_hours_-_hour_10_processing_loops.txt · Last modified: 2022/05/16 03:21 by 127.0.0.1