PreviousScreens PanelsNext"

Chapter 10: Using Screens

This chapter introduces the Screens utility by means of a tutorial. This will help you learn the major facilities available in Screens.

10.1 Tutorial

The following section is a step-by-step tutorial provided to familiarize you with some of the features of the Screens utility. This section will show you how to:

10.1.1 Invoking Screens

To invoke Screens, enter the command line,

DOS and OS/2:
On DOS and OS/2:

screens

Windows:
On Windows:

screensw

UNIX:
On UNIX:

cobrun screens

Windows and OS/2:
Alternatively, on Windows and OS/2, if you have created a group for COBOL, you double-click on the appropriate program icon to invoke the component.

10.1.2 Designing the Sample Form

Having invoked Screens, use text characters and the cursor movement keys to create on your screen the form shown in Figure 10-1.



Figure 10-1: Screens Sample Form

10.1.3 Altering the Current Attribute

We will now change the attribute of the message.

  1. Position the cursor under the W in WARNING MESSAGE.

  2. Press F6 repeatedly to roll through the available attributes. Notice how the word "Attribute" changes on the information line.

  3. Select the desired attribute and press F5. This assigns the desired attribute to the character at the cursor position and moves the cursor one character to the right.

    Continue to press F5 until WARNING is displayed with the new attribute setting. Move the cursor to the M of MESSAGE and press F5 until this is displayed with the new attribute setting.

You can set the attributes for "Name:", "Tel No:", "Address:" and any other part of the screen by following the steps outlined above.

10.1.4 Defining Fields

  1. Position the cursor at the first character position after "Name:".

  2. Enter carets (^ ) to begin defining the "Name:" field. Notice that the carets (^ ) that you are entering are displayed in the current attribute setting. This screen now appears as shown in Figure 10-2.



    Figure 10-2: Form with the Name Field

  3. Position the cursor in the carets for the Name field.

  4. Press F3 to define the carets as a field.

    The carets are replaced by a COBOL picture-string (X's), and a popup menu of Screen Section clauses appears. The word "Field" appears on the information line, as shown in Figure 10-3.



    Figure 10-3: Form with Screen Section Clauses

    We will use the AUTO clause as an example of how to select Screen Section clauses to be included in your program. (Information about this clause is found later in this chapter and in your Language Reference.)


Note: You can select more than one Screen Section clause to be included in your program. Some require additional input (for example, a COBOL identifier for the TO clause). You can also assign a Screen Section name to the current field by selecting <Field name> in the popup menu. See the section Field later in this chapter for details.


10.1.5 Defining Groups

We will now define the "Address:" field as a group. Note that before you can define groups, you must define all fields that are to be repeated; there must be at least one.

  1. Define the Address field immediately after "Address:" by following the steps outlined in the section Defining Fields above.

  2. Position the cursor at the first caret in the "Address" field.

  3. Press F2 to activate the mark option. A reverse video attribute is painted over the character at the cursor position.

  4. Use the <right-arrow> key to move the cursor to the right so that it expands the marked area to cover the entire "Address:" field.

  5. Press F4. This defines the marked area as a group and invokes the Group menu, as shown in Figure 10-4.



    Figure 10-4: Form with the Group Menu

  6. Press F4 four times to vertically repeat the defined area to a total of five lines.

  7. Press Escape to fix the group definition and return to the main menu. This removes the highlighting and restores the field to its original attribute setting.

10.1.6 Defining and Manipulating Blocks of Text and Data

We will now move the highlighted WARNING MESSAGE down one line.

  1. Position the cursor on the W in WARNING MESSAGE.

  2. Press F2 to set the mark option. A reversed video attribute is painted over the character under the cursor.

  3. Use the <right-arrow> and <down-arrow> keys to expand the marked area to cover all of the characters.

  4. Press F7. The marked area is now separated from the rest of the form although its appearance does not change. The Block menu appears on the screen, as shown in Figure 10-5.



    Figure 10-5: Form with the Block Menu

  5. Use the <down-arrow> key to move the block down one line.

  6. Press F2 to paste the block to its current position. The highlighting disappears and you are returned to the main menu.

10.1.7 Altering the Input Field Acceptance Order

If more than one input field exists on a form, you can define the order of field input when the form is accepted. To demonstrate this, we will enter the fields in the following order: Name, Address, Tel No.

  1. Press F10 to set the field input order. The three defined fields display 5's by default.

  2. Position the cursor inside the "Name:" field.

  3. Press 4. This field now displays 4's and will be accepted before the other two fields at run time.

  4. Now position the cursor on the "Tel No:" field.

  5. Press 6. The "Tel No:" field displays 6's and will be the last field accepted at run time.

  6. Now press F10 to turn off the field-order option. The order is saved.

10.1.8 Generating COBOL

You can now generate COBOL code for the form you have just created.

  1. Press Alt+F5. The filename prompt appears at which you enter the name of the COBOL file you want to generate.

  2. Type myform and press Enter. The Generate-COBOL menu appears.

  3. Press F3 from this menu. This generates the skeleton program myform.cbl for the form you have just created.

    The program contains a DISPLAY statement. It also contains an ACCEPT statement since the form contains defined fields. Two other files are also created in the process: a file with generated Working-Storage data (myform.wks) and a Screen Section copyfile (myform.ss). You can now syntax check and run this skeleton program.

    After this program is generated, the system returns you to the main menu and displays the program-name myform at the beginning of the information line.

10.1.9 Creating an Index Program

The Screens facility also lets you generate an entire COBOL program based on a screen that you design. The program generated allows you to key data into the screen. The data is then stored as records in an indexed sequential file.

An indexed sequential file is a data file for which an alphabetic index is automatically maintained. The index is based on a prime key (and optionally three alternate keys) that you specify on your screen form.

In addition to storing data, the index program lets you recall any record from disk, change or delete records, and conduct an alphabetic search through the file regardless of the order in which files were entered.

10.1.9.1 Selecting Code Type

The Screens index generator can produce two different versions of the index program. The first (marked IDX on the generation menu) generates code that relies purely on the Screen Section. The second (marked advanced-IDX on the generation menu) generates code that produces more efficient indexed files. You select the version by using the F8 toggle within the Generate-COBOL menu.

This toggle only works with Micro Focus add-on products.

10.1.9.2 Selecting Index Keys

  1. Press F7 in the Generate-COBOL menu. This will take you into the mark-fields submenu.

  2. Using the cursor keys, move the cursor onto the "Name:" field. Press F2. You will notice that the field has been marked as the PRIME KEY field. Now, when the index program is generated it will store the records in NAME order.

  3. Using the cursor keys move the cursor onto the "TelNo.:" field. Press F3. You will notice that the field has been marked as the ALT2 KEY field. Now, when the index program is generated it will still store the records in NAME order but you will have the option of retrieving them in TEL NO. order.

  4. If you had more fields on your screen you could now go on and mark up to a further two alternate key fields.

  5. If you mark a key field incorrectly you can remove the mark using the F6=unmark-key-field option.

  6. Press Escape to return to the generate-COBOL menu.

  7. Press F5 to generate the index program. The program will be named myform.cbl.

  8. You can now leave Screens. The program you have generated can be used to create and maintain your index program. You might also find it useful as an example of indexed file handling.

10.1.10 Saving the Form

You can now save your form to be used at another time.

  1. Press Alt+F4 from the main menu. The filename prompt appears and displays myform.srn (The extension .srn is assigned by the system as the default file extension for a form created with the Screens facility.)

  2. Press Enter to save the form. The system once again returns you to the main menu.


Copyright © 1999 MERANT International Limited. All rights reserved.
This document and the proprietary marks and names used herein are protected by international law.

PreviousScreens PanelsNext"