Getting Started


Completing the remaining functions

In the functions you just completed, you named some implicit data items, for example LAST and COUNT. VisualAge Generator will create these implicit data items dynamically as needed in the program. You can specify in program properties whether or not VisualAge Generator creates implicit data items.

Two of the performed functions you named, READ-AND-SAVE and MOVE-IT are third or fourth-level performed functions. You must define these functions.

Figure 83. Program Editor

Figure samplp10 not displayed.

Define a I/O option that will read the next record from the database selected by the SETINQ I/O option in the function GET-LIST. Also, specify an error routine that causes an immediate return from the READ-N-SAVE function if an error condition occurs when the record is read.

To define READ-AND-SAVE:

  1. In the Program Editor, double-click on READ-AND-SAVE.

    The New Part Package/Application window is displayed.

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

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

  3. In the I/O Option drop-down list box, select SCAN.
  4. In the I/O Object drop-down list box, select CUSTOMER.
  5. From the Define menu, select Properties.

    The Function Properties window (Figure 84) is displayed.

  6. From the Error routine drop-down list box, select EZERTN.
  7. Select OK.

Figure 84. Function Properties

Figure procprop not displayed.

To supply processing statements for READ-AND-SAVE:

  1. In the Function Editor, enter the following statements after the line containing the I/O option and I/O object:
    if ezesqcod = 0;
    count = count + 1;
    sub = sub + 1;
    move cusnum to cusnum-ws[sub];
    move cusname to cusname-ws[sub];
    move cuscontact to cuscontact-ws[sub];
    move cusphone to cusphone-ws[sub];
    end;
    
  2. From the Tools menu, select Validate and Format.

    VisualAge Generator will validate and format the statements. You must correct any errors before you save the part.

  3. From the File menu, select Save.

    Your function should look like the one shown in Figure 85.

  4. Close the Function Editor.
  5. In the Program Editor, the CUSTOMER record and EZERTN are displayed under READ-AND-SAVE.

Figure 85. Function Editor

Figure rednsav not displayed.

Now, you can define the logic behind MOVE-IT.

Figure 86. Program Editor

Figure samplp11 not displayed.

To define MOVE-IT:

  1. In the Program Editor, double-click on MOVE-IT.

    The new part is created and the New Part Package/Application window is displayed.

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

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

  3. Enter the following statements:
    move 0 to sub;
    move last to sub2;
    set custmap empty;
    while sub < 5 and sub2 < count;
    sub = sub + 1;
    sub2 = sub2 + 1;
    move cusnum-ws[sub2] to cusnum-a[sub];
    move cusname-ws[sub2] to cusname-a[sub];
    move cuscontact-ws[sub2] to cuscontact-a[sub];
    move cusphone-ws[sub2] to cusphone-a[sub];
    end;
    move sub2 to last;
    
  4. From the Tools menu, select Validate and Format.

    VisualAge Generator will validate and format the statements. You must correct any errors before you save the part.

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

    In the Program Editor, MOVE-IT is displayed as defined under FORWARDS and BACKWARDS. Your program should look like the one shown in Figure 87.

Figure 87. Function Editor

Figure samplp12 not displayed.


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