PreviousGlossary of On-line Help Terms Examples and Sample ProgramsNext

Appendix A: Tutorial - ACCEPT/DISPLAY

This tutorial introduces you to character-based programming with Net Express. The program Adsamp.cbl will show you how to set up a character screen for the user and receive input from it.

You will learn how to use the Enhanced ACCEPT/DISPLAY syntax (Adis) to display a data entry screen in the COBOL text window. Then you will accept input data from the user. This means that you must already have specified which keys can be used to terminate the ACCEPT; you'll do this too.

So, follow the sections below in turn to follow the tutorial step by step:

  1. Preparing the ADSAMP program
  2. Specifying keys to terminate the ACCEPT
  3. Displaying the data entry screen
  4. Accepting the data
  5. Querying the user's input

A.1 Step 1 - Preparing the ADSAMP program

  1. Click the Net Express icon from Start, Programs, MERANT Net Express, to invoke Net Express. Load the Adsamp project by clicking File, Open from within Net Express, and looking in the \demo directory. Double-click Adsamp.cbl to open the program.
  2. Click to compile Adsamp.cbl. When this is done, "Rebuild complete" appears in the output area.
  3. Click Start Animating on the Animate menu to start animating Adsamp.
  4. In the dialog box, click OK. The first line of the program is highlighted and you are ready to begin.

A.2 Step 2 - Specifying keys to terminate the ACCEPT

The ACCEPT/DISPLAY module ("XAF") enables you to specify exactly which keys the user can press to terminate the ACCEPT when all data has been entered. It also enables you to disable other keys.

  1. Click to execute the first statement.

    Set-bit-pairs is the function you want the ACCEPT/DISPLAY module to perform at the moment, setting which function keys you want enabled.

    Enable-esc-and-f1 is a group item which is set up to enable only the two function keys Escape and F1. The second elementary parameter is set to the value "1" to denote a user function key.

  2. Click to execute the second statement.

    Here you've used the same function with a different second parameter. Disable-all-other-user-keys is a group item which is set up to disable all function keys other than Escape and F1. The second elementary parameter still has a value "1", as you'd expect.

  3. Click to execute the third statement.

    This statement enables the "/" key so that the user can enter "/h" rather than F1 to get help.

    This is a data key rather than a function key, so the second elementary parameter is "3". You'll see how this works in the final tutorial topic.

A.3 Step 3 - Displaying the data entry screen

  1. First, click twice to set up the cursor position; you want to set the cursor at the start of the first field.

    The cursor-position field is referenced in the Cursor is clause of Special-names.

  2. Click once to move in to the perform, then again to execute the display statement.

    The data entry screen is displayed in the COBOL text window. You can't enter any data yet, though.

A.4 Step 4 - Accepting the data

  1. Click to execute the accept statement.

  2. Enter some data in to the fields in the data entry screen.

  3. Press F1.

    Since you've specifically enabled this function key, you're returned to the program. Pressing Escape or the "/" key would have done the same, but no other function or data key would have terminated the accept.

  4. Right-click on key-type and click Locate "key-type" on the popup menu.

    The key-status parameter is referenced in the crt status clause of Special-names, and contains details of how the accept was terminated.

  5. Right-click anywhere within the Adsamp window, and click Return on the popup menu.

A.5 Step 5 - Querying the user's input

  1. Click to execute the evaluate statement.

    The "1" condition is true, since this is the code for a user function key (notice the "0" condition, which is true when you press Enter to terminate the ACCEPT).

  2. Click again, then double click key-code-1.

    You'll see that the value is 1, which is the code for the function key F1. The program now knows exactly which key was pressed to terminate the ACCEPT.

  3. Click again, then again.

    The action of clicking F1 tells the program to invoke the Help screen.

  4. Click to move to the display-help-screen section, then again to display the screen itself in the COBOL text window.

    The next call to the ACCEPT/DISPLAY module is a different function from the set-bit-pairs call you used before. This time it gets a single character from the user, rather than accepting data as you did before.

  5. Click to execute the call.

    Any key returns you from the Help screen to the program.

When you're familiar with the workings of the Adsamp program, try using the set-bit-pairs call to enable different keys. Then set a breakpoint at the evaluate key-type statement. Go round the loop, pressing a different key each time, and seeing what this does to the values in key-status.


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

PreviousGlossary of On-line Help Terms Examples and Sample ProgramsNext