sams_teach_yourself_cobol_in_24_hours_-_hour_4_basic_user_interface

Sams Teach Yourself COBOL in 24 Hours - Hour 4 Basic User Interface

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

Hour 4 Basic User Interface

In Hour 3, “Different Data Types,” you learned about the various types of fields available in a COBOL program and a little bit about how to use them. The data used by your COBOL programs is useful only when presented to an end user, the person for whom your program was written. To that end, some interface with the user must exist. This hour focuses on aspects of the user interface, including

Definitions of and the differences between batch and interactive processing

Using the keyboard and screen to interface with the user

Using the COBOL Screen Section to interact with the user

Interfacing with the User You cannot create a useful program unless you are able to interact with the user. Your user may be a person who runs your program, or another program or process that passes information to your program for processing.

Until recently, the COBOL language did not have a built-in method for interfacing with a human user. By using add-on tools, provided by different vendors, you may add simple or complex user interfaces to your programs. COBOL, historically used to process large volumes of business data, did not initially need a way to gather data from a human user. The invention of the desktop personal computer changed all of that.

Batch Versus Interactive Processing Traditionally, computers processed data in large batches. The transactions were gathered together in groups, and then these files of transactions were applied to a master file. Processes with the sole function of reading input data and writing related output are called batch processes. Batch processes typically run without any human interaction.

Interactive processing involves a user interacting with a program, somewhat like having a conversation with the computer. This type of give and take with the user, accepting data and displaying results, is called interactive processing. In the early days of COBOL when the language was available only on large mainframe computers, special methods were developed to communicate between the user and the COBOL program. One of the more successful and prevalent in the IBM mainframe world is called Customer Information Control System, or CICS. CICS is still in use; it relies on a special IBM-defined syntax for the program to communicate with CICS, which communicates with the user.

The Screen Section COBOL compilers were available with the very first PCs. Having no user interface, the different compilers made use of some vendor-specific extensions to the Display and Accept verbs.

Image

In reference to COBOL, a verb and a statement are synonymous.

The one revision to the ANSI COBOL standard that has been completed since the invention of the PC did not address the user interface. The different makers of compilers for the PC used different methods for addressing the user interface problem. Before graphical user interfaces came on the scene, a normal text mode interface, similar to that utilized on large mainframe computers was used. However, the differences among the different compilers made it difficult to transition from one COBOL to another. This problem with the user interface is virtually the only issue that prevents COBOL from being a truly unrestricted cross-platform-compatible programming language.

COBOL was and is also in heavy use on UNIX systems. The X/Open committee concerned itself heavily with UNIX issues and worked with the different compiler vendors to develop a standard for the text mode user interface. The result of this standard is the Screen Section.

The Screen Section, not being part of the current ANSI standard, is not implemented exactly the same way among the different compiler vendors, nor do all of them use it. However, it has gained enough usage to be a part of the new COBOL standard currently under consideration.

Image

The Screen Section provides a more than adequate user interface for the programs in this book and for learning COBOL. Most PC compilers support some minor variation of the Screen Section. Even if you are not using the Fujitsu compiler that comes with this book, you should be able to compile and run the examples and exercises with minor modifications.

Elements of the Screen Section The Screen Section appears in the Data Division, after the Working-Storage Section. A Screen Section may have several screen descriptions. A screen description has several elements. The first is the screen literal, which is where you want textual information to appear onscreen; no user entry is necessary. Another element is data you want to display, but not allow the user to change. A third element is data that you want to display and preserve. In this case, the user keys into a field on the screen, corresponding to the same screen location, but the data is stored in a different location in Working-Storage. The last element of a screen description is a field that you want to update. In an update field, an initial value is displayed for the user and is then updated.

The Screen Section works by using simple Display and Accept statements. A screen is first displayed, and then the same screen definition is accepted and the input is processed.

The first portion of the screen description is a level 01 group item. This item describes the name of the screen and any special attributes that are to be applied to the entire screen. If these are specified, they will be applied to all subordinate items in this screen. These special attributes are

Blank Screen

• Foreground-Color

Background-Color

Sign

Usage

Auto

Full

Secure

Required

The Blank Screen clause clears the screen.

The Foreground-Color and Background-Color clauses specify the colors for the display. Valid colors are described with integer values between 0 and 7. (See Table 4.1.)

Table 4.1 Display Color Values

Image

The behavior of the Sign clause was described in Hour 2, “Writing Your First Program in COBOL.” If used at the group level of a screen description, this clause causes all numeric signed fields to store the sign as specified (Separate, Leading, or Trailing).

The behavior of the Usage clause was discussed in Hour 3. Applying the Usage at the group level of a screen description reduces the need for repetitive specification of the Usage on numeric items.

The Auto clause causes the cursor to skip to the next field onscreen when you have keyed all available data into the field where the cursor is located. Using the Auto clause makes data entry much easier for the user. When Auto is specified, if the last field onscreen is filled, the Accept will be terminated.

Using the Full clause requires the user to fill the entire field before advancing to the next field. For alphanumeric items, a character must be input into the first and last positions of the field. For numeric items, zeros or a number must be input into each position of the field. If the field is zero suppressed, only those digits not suppressed are required entries.

The Full clause is ignored if the Accept operation is terminated with a function key.

Secure allows the screen to accept user input, but does not display the characters that are entered. It is useful for password entry.

Required forces the user to enter at least one character into each input or update field in the associated screen description. Like the Full clause, if a function key terminates the Accept, the Required clause is ignored.

In the following example, a Group Level screen description entry requires the user to enter a value in each input field and automatically advances to the next field when each field is full. The foreground color is white, and the background color is blue. The screen is cleared when this screen description is displayed.

000020 Screen Section. 000021 01 My-Main-Screen 000022 Blank Screen, Auto, Required, 000023 Foreground-Color is 7, 000024 Background-Color is 1. Image

The commas used as punctuation in the example are optional. The COBOL compiler ignores them when compiling your program. You may spread the clauses over multiple lines, terminating the level with a period.

Screen Literals Screen literals are specified using their values and the Line and Column numbers at which they are to appear. No Picture clause is coded for a screen literal. A data name may follow the level number of a literal, or you may use Filler. If no data name is specified, Filler is assumed. In addition to the Line and Column, the following special clauses may be applied. The clauses that are the same as those for Group Level screen description entries follow the previously discussed rules.

Blank Screen

Blank Line

Erase

• Foreground-Color

Background-Color

Blink

Highlight

Lowlight

Reverse-Video

Underline

Bell

The Blank Line clause causes the line on which the elementary screen item appears to be cleared before the screen is displayed.

The Erase clause is followed by one of two values. EOL causes the erase to clear from the beginning column of the screen item to the end of the line. EOS causes the screen to be cleared from the beginning of the screen item to the end of the screen.

Blink causes the associated screen item to blink onscreen.

Highlight causes the associated screen item to be highlighted, or brightened, onscreen.

Lowlight causes the associated screen item to be dimmed. If the system does not support the dimming of an item, standard intensity is used. For a PC, this is the case.

Reverse-Video reverses the values of the foreground and background colors of screen items.

Underline causes the screen item to appear underlined on systems that support the underlined display attribute. The Fujitsu compiler on the PC supports the use of the Underline clause.

The Bell clause causes a beep or bell to sound when the screen item is displayed. It can be used to get the attention of the user.

The Line Number and Column Number clauses specify the line and column position of the first character in the screen item. The first line on the screen is Line 1, and the first column is Column 1. You may abbreviate the clause by leaving out the word Number, specifying only Line or Column. The following expanded example shows some screen literals. The first is an underlined heading line. The next is a name field heading that is highlighted and sounds the bell when displayed. Take special note of the subordinate level numbers.

000020 Screen Section. 000021 01 My-Main-Screen 000022 Blank Screen, Auto, Required, 000023 Foreground-Color is 7, 000024 Background-Color is 1. 000025 03 Line 01 Column 27 ValueName and Address Entry” 000026 Underline. 000027 03 Line 3 Column 5 ValueLast NameHighlight Bell.

Using From An output item is described using From on an elementary level of a Screen Section screen description entry. From utilizes an item described in the Data Division and places it on the display in the position specified and using the attributes specified. The following special clauses may be specified with an output, input, or update item. Clauses that have already been discussed follow the previously covered rules.

Auto

Required

Secure

Full

Blank Line

Blank Screen

Erase

• Foreground-Color

Background-Color

Highlight

Lowlight

Underline

Blink

Bell

Sign

Usage

Picture

Justified

Blank When Zero

The newly introduced items are Picture, Justified, and Blank When Zero. The Picture clause can be any valid Picture clause. This clause can be extremely useful. You can specify an edit pattern for field display while having a very different Usage specified for the field.

Blank When Zero is used for numeric or numeric edited item to cause the screen to display the field as spaces if the value of the item referenced is zero.

The Justified clause (abbreviated Just) has only one possible value, and that is Justified Right. This clause positions an alphanumeric field into the screen item that may be smaller or larger. Normally when an alphanumeric item is moved, if it is larger than the destination field, the right-most characters are lost. By specifying Justified Right, if a smaller item is referenced, the characters to the left are truncated. If the item being referenced is smaller, then the left-most positions are filled with spaces.

Listing 4.1 is an example of a Screen Section using From to display two output fields. The first is a numeric edited field in which the screen displays spaces if the field is zero. The second is a small alphanumeric item. The third is the same alphanumeric item with Justified Right specified, as an illustration of its behavior.

Listing 4.1 Demonstrate Screen Section with Justified Right

000001 @OPTIONS MAIN 000002 Identification Division. 000003 Program-Id. Chapt04a. 000004 Environment Division. 000005 Configuration Section. 000006 Source-Computer. IBM-PC. 000007 Object-Computer. IBM-PC. 000008 Data Division. 000009 Working-Storage Section. 000010 01 Dollar-Amount Pic 9(5)v99 Value 12.99. 000011 01 Item-Description Pic X(10) Value “Gold Coins”. 000012 Screen Section. 000013 01 Main-Screen 000014 Blank Screen, Auto, Required, 000015 Foreground-Color is 7, 000016 Background-Color is 1. 000017 03 Line 1 Column 35 ValueItem Entry”. 000018 03 Line 3 Column 5 ValueItem ValueHighlight Bell. 000019 03 Line 3 Column 16 Pic $$,$$$.99 From Dollar-Amount. 000020 03 Line 5 Column 5 ValueItem DescriptionHighlight. 000021 03 Line 5 Column 22 Pic x(10) From Item-Description. 000022 03 Line 6 Column 4 Value “Short DescriptionHighlight. 000023 03 Line 6 Column 22 Pic x(5) From Item-Description. 000024 Justified Right. 000025 Procedure Division. 000026 Chapt04a-Start. 000027 Display Main-Screen. 000028 Stop Run. The output of this Screen Section shows the edit pattern applied to the numeric field. It also shows the action of the Justified Right clause. Notice how with the Short Description, only the word Coins is displayed, even though the From clause specifies the same data item in both lines 5 and lines 6 of the display.

Figure 4.1 Example of a Screen Section.

Image

Image

When displaying or accepting a screen description, if no Line and Column numbers are specified in the Display or Accept statements, then the Line and Column numbers specified for the elementary items in the Screen Section are used. However, if Line and Column numbers are specified on the Display statement, then that Line and Column are the offset for the screen definition. For example, if an item was defined in a screen description to reside at Line 2 and Column 10 and the display of the screen description was at Line 5 and Column 15, the item would appear at Line 6, Column 24.

Using To Specifying To on a screen description elementary item creates an input field. The same special clauses that are used with From are available with To. When using To, the contents of the field are not shown on the screen when the screen description is displayed. As data is keyed into the field, it appears onscreen. However, the next time the screen description is displayed, it does not appear. Input is accepted into the data items referenced in the screen description by use of an Accept statement.

000055 Accept Main-Screen. Image

Take special care when using Justified Right with an input field. As your data is keyed into the input field, it will be left-justified, and will not be positioned in the field as you might expect when using Justified Right. Justified Right is only used to position the field in the display. When the screen description is accepted, the field, exactly as the user keyed it, will reside in the target field. I suggest that Justified Right clause be used sparingly, if at all.

To and From can be used together for the same screen description elementary item. Doing so causes one item from the Data Division to be displayed while accepting data into a different data item. This approach can be used to preserve the original display field.

000032 03 Line 6 Column 22 Pic x(5) From Item-Description 000033 To New-Item-Description.

Using Using When Using is specified, an update item is created. An update item displays and accepts input into the same data area. Any changes are shown when the screen description is next displayed. An update item may have the same special clauses as input and output items. Using allows you to use a single data item for display and update by the user.

Special-Names Paragraph When using the Screen Section, you sometimes have to capture and set the cursor location. In addition, specific function keys can be activated that may be detected by your program. If no function keys are activated, the only key that can terminate the Accept of a screen description is the Enter key.

To capture the cursor and the function keys, you need to make entries in the Special-Names paragraph of the Configuration Section. These entries relate the actual cursor position and function key status to Working-Storage data items that you can reference in the program. The two special names you will assign are Cursor and Crt Status.

Cursor is the position of the cursor. When you make the Special-Names entry, you are specifying a data item that contains the row and column of the position of the cursor. When a screen definition is displayed, the cursor appears at the field, with the starting position closest to, but not less than, the row and column specified in the cursor field. The field referenced by the Cursor special name must be either four or six characters long. If four characters, the first two are the row and the last two are the column of the cursor position. If the field is six characters long, then the first three correspond to the row and the last three to the column.

000005 Configuration Section. 000006 Special-Names. 000007 Cursor is Cursor-Position. 000008 Source-Computer. IBM-PC. 000009 Object-Computer. IBM-PC. 000010 Data Division. 000011 Working-Storage Section. 000012 01 Cursor-Position. 000013 03 Cursor-Row Pic 9(2) value 1. 000014 03 Cursor-Column Pic 9(2) value 1. Line 6 starts the Special-Names paragraph. Only the last item in the paragraph should be followed by a period. The Special-Names entry, Cursor, for example, starts in Area B (column 12).

Image

Some compilers differ in the area of the specifications for the Cursor Special-Names entry. The cursor position field for the VMS COBOL compiler DEC/Alpha systems may be either four or five positions long. If four positions, the first two positions are the row and the last two the column. If five positions long, the last three are the column number. If you are not using the Fujitsu compiler, see the language reference provided with your compiler to determine the proper values for the Cursor Special-Names entry.

The other Special-Names entry associated with the Screen Section is Crt Status.

The field assigned to the Crt Status special name is three characters long. The first two positions provide codes that correspond to the reason for the termination of the Accept. The system uses the third position for internal housekeeping and should not be referenced.

It is useful to define this status value as a Group Level item with three subordinate elementary items corresponding to the three individual return characters.

000013 01 Keyboard-Status. 000014 03 Accept-Status Pic 9. 000015 03 Function-Key Pic X. 000016 03 System-Use Pic X. The first character, Accept-Status, contains a 0 if the Accept is terminated normally, either by the Enter key being pressed or by the last field in the screen definition being filled when the Auto clause is specified. In this case, the second character, Accept-Status, contains either a 0 or a 1. A value of 0 means that the user terminated the Accept by pressing Enter. A value of 1 means that the user filled the last field of the screen and the Accept was terminated because the Auto clause was specified.

Accept-Status has a value of 1 or 2 if the accept statement is terminated by the press of a function key. In this case, the second field contains a coded value corresponding to the function key that is pressed. A value of 1 in the Accept-Status field indicates that a default function key terminated the Accept, whereas a value of 2 indicates a user-defined function key.

Image

The size and meaning of the Crt Status data item depend on the COBOL compiler. If you are not using the Fujitsu compiler, check your documentation for the appropriate size and meanings for the different values.

000005 Configuration Section. 000006 Special-Names. 000007 Crt Status is Keyboard-Status 000008 Cursor is Cursor-Position. 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 03 System-Use Pic X. 000017 01 Cursor-Position. 000018 03 Cursor-Row Pic 9(2) Value 1. 000019 03 Cursor-Column Pic 9(2) Value 1. Image

Notice the single period after the statements in the Special-Names paragraph. If you need to specify any other items in the Special-Names paragraph, remember to use a single period after the last item only. Additionally, some compilers are sensitive to the order of items listed in the Configuration Section. If you have trouble compiling the program under a different compiler, try placing the Special-Names paragraph after the Source-Computer and Object-Computer paragraphs.

Using the Screen Section in a Program The simple data entry screen in the following example gathers information about the different sellers in a consignment store. Before designing any screens, you need to consider the requirements. What kind of data is to be collected? How is it to be displayed? What do you want the screen to look like? The program displays a screen and then waits for the user to enter the data. Some default values are provided so that the user does not need to key everything.

First, decide which items you need to track and the size you want to assign to them. Be very careful to make the fields large enough without being wasteful. COBOL programmers are always mindful of future maintenance needs in their programs. Create yours with that in mind, and if you or other programmers have to modify the program, the task will be easy.

The program tracks the following items for each tenant, using the specified field types and lengths. The default value to assign is also listed.

Last NameAlphanumeric 25 characters

First NameAlphanumeric 15 characters

• Middle NameAlphanumeric 10 characters

Address Line 1—Alphanumeric 50 characters

Address Line 2—Alphanumeric 50 characters

• City—Alphanumeric 40 characters

State or Country—Alphanumeric 20 characters

• Postal CodeAlphanumeric 15 characters

• Home Telephone—Alphanumeric 20 characters

Work Telephone—Alphanumeric 20 characters

• Other Telephone—Alphanumeric 20 characters

Start DateNumeric eight digits, formatted MM/DD/YYYY

Last Rent Paid DateNumeric eight digits, formatted MM/DD/YYYY

• Next Rent Due DateNumeric eight digits, formatted MM/DD/YYYY

• Rent AmountNumeric six digits, two decimal positions, default $50.00

Consignment Percentage—Numeric three digits, default 40

Take special notice of the extra space in the Postal Code and Telephone Number fields. Also, notice that the dates are eight digits long, even though with the slashes they fill 10 display positions.

The required fields are First Name, Last Name, Home Telephone, Start Date, Rent Amount, and Consignment Percentage. Try to format the screen clearly and neatly, using literals to title the various fields. Make the entry fields reverse video to differentiate them from the screen literals.

The screen requires a title describing its purpose and a fancy store name. Use Darlene's Treasures. Listing 4.2 is one way to code the Screen Section.

Key the following program into the editor and name it Chapt04C.Cob.

Listing 4.2 Screen Section Demonstration

000001 @OPTIONS MAIN 000002 Identification Division. 000003 Program-Id. Chapt04c. 000004* Data entry Screen 000005 Environment Division. 000006 Configuration Section. 000007 Special-Names. 000008 Crt Status is Keyboard-Status 000009 Cursor is Cursor-Position. 000010 Source-Computer. IBM-PC. 000011 Object-Computer. IBM-PC. 000012 Data Division. 000013 Working-Storage Section. 000014 01 Keyboard-Status. 000015 03 Accept-Status Pic 9. 000016 03 Function-key Pic X. 000017 03 System-Use Pic X. 000018 01 Cursor-Position. 000019 03 Cursor-Row Pic 9(2) Value 1. 000020 03 Cursor-Column Pic 9(2) Value 1. 000021 01 Screen-Items. 000022 03 Last-Name Pic X(25) Value Spaces. 000023 03 First-Name Pic X(15) Value Spaces. 000024 03 Middle-Name Pic X(10) Value Spaces. 000025 03 Address-Line-1 Pic X(50) Value Spaces. 000026 03 Address-Line-2 Pic X(50) Value Spaces. 000027 03 City Pic X(40) Value Spaces. 000028 03 State-or-Country Pic X(20) Value Spaces. 000029 03 Postal-Code Pic X(15) Value Spaces. 000030 03 Home-Phone Pic X(20) Value Spaces. 000031 03 Work-Phone Pic X(20) Value Spaces. 000032 03 Other-Phone Pic X(20) Value Spaces. 000033 03 Start-Date Pic 9(8) Value Zeros. 000034 03 Last-Rent-Paid-Date Pic 9(8) Value Zeros. 000035 03 Next-Rent-Due-Date Pic 9(8) Value Zeros. 000036 03 Rent-Amount Pic 9(4)V99 Value 50.00. 000037 03 Consignment-Percent Pic 9(3) Value 40. 000038 Screen Section. 000039 01 Data-Entry-Screen 000040 Blank Screen, Auto 000041 Foreground-Color is 7, 000042 Background-Color is 1. 000043 03 Line 01 Column 30 Value “Darlene’s Treasures” 000044 Highlight Foreground-Color 4 Background-Color 1. 000045 03 Line 03 Column 30 ValueTenant Entry Program” 000046 Highlight. 000047* 000048 03 Line 5 Column 01 ValueName, Last: ”. 000049 03 Line 5 Column 13 Pic X(25) Using Last-Name 000050 Reverse-Video Required. 000051 03 Line 5 Column 39 ValueFirst: ”. 000052 03 Line 5 Column 46 Pic X(15) Using First-Name 000053 Reverse-Video Required. 000054 03 Line 5 Column 62 Value “Middle: ”. 000055 03 Line 5 Column 70 Pic X(10) Using Middle-Name 000056 Reverse-Video. 000057* 000058 03 Line 6 Column 01 ValueAddress 1: ”. 000059 03 Line 6 Column 15 Pic X(50) Using Address-Line-1 000060 Reverse-Video. 000061* 000062 03 Line 7 Column 01 ValueAddress 2: ”. 000063 03 Line 7 Column 15 Pic X(50) Using Address-Line-2 000064 Reverse-Video. 000065* 000066 03 Line 8 Column 01 Value “City: ”. 000067 03 Line 8 Column 15 Pic X(40) Using City 000068 Reverse-Video. 000069* 000070 03 Line 9 Column 01 ValueCountry/State: ”. 000071 03 Line 9 Column 15 Pic X(20) Using State-Or-Country 000072 Reverse-Video. 000073 03 Line 9 Column 36 Value “Postal Code: ”. 000074 03 Line 9 Column 50 Pic X(15) Using Postal-Code 000075 Reverse-Video. 000076* 000077 03 Line 11 Column 01 Value “Phone/Home: ”. 000078 03 Line 11 Column 13 Pic X(20) Using Home-Phone 000079 Reverse-Video. 000080 03 Line 11 Column 34 ValueWork: ”. 000081 03 Line 11 Column 41 Pic X(20) Using Work-Phone 000082 Reverse-Video. 000083* 000084 03 Line 12 Column 06 Value “Other: ”. 000085 03 Line 12 Column 13 Pic X(20) Using Other-phone 000086 Reverse-Video. 000087* 000088 03 Line 14 Column 01 ValueStart Date: ”. 000089 03 Line 14 Column 13 Pic 99/99/9999 Using Start-Date 000090 Reverse-Video. 000091 03 Line 14 Column 24 ValueLast Paid Date: ”. 000092 03 Line 14 Column 40 Pic 99/99/9999 Using Last-Rent-Paid-Date 000093 Reverse-Video. 000094 03 Line 14 Column 50 Value “Next Rent Due on: ”. 000095 03 Line 14 Column 68 Pic 99/99/9999 Using Next-Rent-Due-Date 000096 Reverse-Video. 000097 03 Line 15 Column 01 Value “Rent Amount: ”. 000098 03 Line 15 Column 14 Pic Z,ZZZ.99 Using Rent-Amount. 000099 03 Line 16 Column 01 ValueConsignment Percent: ” 000100 Reverse-Video. 000101 03 Line 16 Column 22 Pic ZZ9 Using Consignment-Percent 000102 Reverse Video. 000103 Procedure Division. 000104 Chapt04c-Start. 000105 display Data-Entry-Screen. 000106 accept Data-Entry-Screen. 000107 Stop Run. Notice the comment lines (indicated by an * in column 7) that separate the code and make the program more readable. COBOL also tolerates plain blank lines. The fields are grouped so that the text literal appears in the screen definition before its associated field. Look at the Value clauses in use and the special screen colors. Pay special attention to the way that the subordinate data items override the attributes of the higher levels. If most of a screen is to be one color, you can code that color at the major Group Level and then override that color for individual fields at the subgroup level or even at the Elementary item Level.

Image

When you key this program and compile it, you are liable to have typographical errors. Now is a good time to get used to correcting these errors from the compile listing. Remember that you can position the cursor on the first character of an error line and press F11 to jump to the editor screen, where you are automatically positioned at the source line that is in error. Although your compile listing may seem to disappear at this point, it hasn't. You can make your change, realizing that an error, such as a missing period on one line, can cause errors to be reported on other lines that, in fact, are correct. After making the change, you can save the program and then exit the editor to return to the compile listing, or you can minimize the edit window to see the compile listing. Another method is to click on the Window menu and select the program file you're working on. Positioning the cursor on the next error and pressing F11 repositions the cursor in the source edit window. Maximizing the edit window then displays the line in error. Alternatively, you can choose to tile the two windows.

Image

When you save your program for the first time, make sure to specify the entire name of the program file, including the .COB file extension. If you fail to do so, you may not see your program when you try to reopen it. If that happens, rename the file to have the .COB file extension.

Figure 4.2 Chapt04c screen image.

Image

A better, less verbose way to code the preceding Screen Section is to organize fields with the same display characteristics under a single group. This way, elements such as Reverse-Video don't need to be coded for each elementary item. The following example shows another way to code this Screen Section.

000038 Screen Section. 000039 01 Data-Entry-Screen 000040 Blank Screen, Auto 000041 Foreground-Color is 7, 000042 Background-Color is 1. 000043* 000044 03 Screen-Literal-Group. 000045 05 Line 01 Column 30 Value “Darlene’s Treasures” 000046 Highlight Foreground-Color 4 Background-Color 1. 000047 05 Line 03 Column 30 ValueTenant Entry Program” 000048 Highlight. 000049 05 Line 5 Column 01 ValueName, Last: ”. 000050 05 Line 5 Column 39 ValueFirst: ”. 000051 05 Line 5 Column 62 Value “Middle: ”. 000052 05 Line 6 Column 01 ValueAddress 1: ”. 000053 05 Line 7 Column 01 ValueAddress 2: ”. 000054 05 Line 8 Column 01 Value “City: ”. 000055 05 Line 9 Column 01 ValueCountry/State: ”. 000056 05 Line 9 Column 36 Value “Postal Code: ”. 000057 05 Line 11 Column 01 Value “Phone/Home: ”. 000058 05 Line 11 Column 34 ValueWork: ”. 000059 05 Line 12 Column 06 Value “Other: ”. 000060 05 Line 14 Column 01 ValueStart Date: ”. 000061 05 Line 14 Column 24 ValueLast Paid Date: ”. 000062 05 Line 14 Column 50 Value “Next Rent Due on: ”. 000063 05 Line 15 Column 01 Value “Rent Amount:”. 000064 05 Line 16 Column 01 ValueConsignment Percent: ”. 000065 03 Required-Reverse-Group Reverse-Video Required. 000066 05 Line 5 Column 13 Pic X(25) Using Last-Name. 000067 05 Line 5 Column 46 Pic X(15) Using First-Name. 000068* 000069 03 Reverse-Video-Group Reverse-Video. 000070 05 Line 5 Column 70 Pic X(10) Using Middle-Name. 000071 05 Line 6 Column 15 Pic X(50) Using Address-Line-1. 000072 05 Line 7 Column 15 Pic X(50) Using Address-Line-2. 000073 05 Line 8 Column 15 Pic X(40) Using City. 000074 05 Line 9 Column 15 Pic X(20) Using State-Or-Country. 000075 05 Line 9 Column 50 Pic X(15) Using Postal-Code. 000076 05 Line 11 Column 13 Pic X(20) Using Home-Phone. 000077 05 Line 11 Column 41 Pic X(20) Using Work-Phone. 000078 05 Line 12 Column 13 Pic X(20) Using Other-phone. 000079 05 Line 14 Column 13 Pic 99/99/9999 Using Start-Date. 000080 05 Line 14 Column 40 Pic 99/99/9999 000081 Using Last-Rent-Paid-Date. 000082 05 Line 14 Column 68 Pic 99/99/9999 000083 Using Next-Rent-Due-Date. 000084 05 Line 15 Column 14 Pic Z,ZZZ.99 Using Rent-Amount. 000085 05 Line 16 Column 22 Pic ZZ9 Using Consignment-Percent. Run the program and experiment with it. Notice that you cannot leave the Last Name field by tabbing or by pressing the Enter key until you key some data. You must enter some data because Last Name is a required field. However, the Enter key does work after some data is keyed into the Last Name field, although First Name is also a required field. The Required attribute is in effect only while the cursor is on a field that is required. Once the requirement is satisfied for that field, Enter or Tab will work.

Also, note that only numbers may be entered in the date fields. Try to key in some letters and see what happens. You may key the slashes or omit them as you desire; the fields are always formatted with the slashes in the proper positions.

Summary In this hour, you learned

• About the Screen Section and its development

• How to create a screen definition

• How to apply an edit pattern to a field used in a screen definition

• How to use input, output, and update fields

• How to use Special-Names entries to get and control the cursor position and detect function keys

• Efficient ways of coding a screen definition

Q&A Q What are the different elements of the Screen Section?

A A Screen Section is made up of one or more screen definitions. A screen definition consists of screen literals and input, output, and update fields.

Q What is the difference between using Using and defining a screen element with both From and To fields?

A Specifying Using causes a field to be displayed and then updated when the user keys data into the field. Specifying From and To causes data to be displayed from one field but accepted into another.

Q How can the position of the cursor be determined?

A As you write more complex programs, you will need to know which field the cursor was on last and how to position it there. When using a Screen Section, you use the Special-Names paragraph of the Configuration Section to specify a field in Working-Storage for tracking the cursor position.

Q Can more than one screen definition be present in a program?

A Yes. You can specify multiple screen definitions in a Screen Section. Start each new definition with a new level 01 group.

Workshop To help reinforce your understanding of the material presented in this hour, refer to the sectionQuiz 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]] [[Source]]s

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_4_basic_user_interface.txt · Last modified: 2022/05/17 07:18 by 127.0.0.1