Getting Started


Defining a main function

A function provides the basic unit of the logic structure for a program. For example, input and output operations that take place are done in functions.

A single function can contain only one I/O operation. However, a function is not required to contain an I/O operation. In this tutorial, your sample program includes some functions that include an I/O operation and some that don't.

You need to build a simple logic structure within the main function you have defined. This allows you to do a quick, basic definition of the overall structure of the program.

Figure 48. Program Editor

Figure samplpr2 not displayed.

To begin building the program structure:

  1. In the Program Editor double-click on MAIN-LOGIC.

    The New Part Package/Application window is displayed.

    Figure 49. New Part Package/Application

    Figure winnpapp not displayed.

  2. Ensure that tutorial is selected, and select OK.
  3. Type the statements as shown in Figure 50.
    Note:You can type in lowercase. The editor will convert your code to uppercase when you select Save, Validate, or Validate and Format.

    Figure 50. Function Editor

    Function Editor

    Each line in this function invokes the function named.

  4. Ensure that EXECUTE is displayed in the I/O option drop-down list box.

    The list box on the left displays I/O options, which define the type of operation a function will carry out. The list box on the right displays I/O objects, the data parts on which I/O options are performed. The EXECUTE option does not have an I/O object. Here it is used to control the flow between functions.

  5. From the Tools menu, select Validate and Format.
  6. From the File menu, select Save.
  7. Close the Function Editor.

Now you can partially define each of the performed functions. By partially defining these functions, you can test the program structure without completely defining the program. You can supply the logic of the program later. Providing partial definitions of the program and its components is one way to use VisualAge Generator Developer for rapid prototyping.

  1. In Program Editor, click on the + beside MAIN-LOGIC.

    That branch of the structure diagram is expanded.

  2. Double-click on CONVERSE-MAP.

    The New Part Package/Application window is displayed.

  3. Ensure that tutorial is selected, and select OK.

    The new part is created and the Function Editor is displayed.

  4. From the I/O options drop-down list box, select CONVERSE.
  5. In the I/O object drop-down list box, type custmap.
  6. From the File menu, select Save.
  7. Close the Function Editor.

To define an I/O option and an I/O object for GET-LIST:

  1. In the Program Editor double-click on GET-LIST.

    The New Part Package/Application window is displayed.

  2. Select OK.
  3. From the I/O options drop-down list box, select SETINQ.

    The SETINQ option selects a set of rows from an SQL row record.

  4. In the I/O object drop-down list box, type customer.

    Customer is the name you will use when you define the SQL row record that SETINQ will select from.

  5. From the File menu, select Save.
  6. Close the Function Editor.

Your program structure should look like the one shown in Figure 51.

Figure 51. Program Diagram

Figure samplpr3 not displayed.

Summary of creating a function

All functions for a program are created using the steps you just completed. The following is a summary of those steps:

  1. In the Program Editor, double-click on the function name in the structure diagram.
  2. On the New Part Package/Application window, select OK to add the part to the selected package/application.
  3. In the Function Editor, select an I/O option and an I/O object, and enter statements.
  4. Save the statements, then close the Function Editor.


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]