Invoking a Map with INPUT USING MAP

#### Search Results

Search

# Invoking a Map with INPUT USING MAP

In this session, you will create and execute the example program PROG001 to test the effect of the `INPUT USING MAP` statement, which invokes map MAP001.

PROG001 is provided in the Natural system library SYSEXPG; ask your Natural system administrator for details.

To create and execute PROG001

1. If you have access to a copy of PROG001, in the command line of the Edit Map menu, enter the following:

       EDIT PROG001

   The program editor is invoked and the source code of PROG001 is displayed in the editing area. Make sure that the program is identical to the one shown below.

   Or:
   If you do not have access to a copy of PROG001, in the command line of the Edit Map menu, enter the following:

       EDIT PROGRAM

   The program editor is invoked. If necessary, clear the editing area by entering the command `CLEAR` at the program editor's command prompt (`>`). Then type in the following program:

   #### PROG001:

       ** Example 'PROG001': Example program for the Map Tutorial
       ************************************************************************
        DEFINE DATA LOCAL
        01 PERS-VIEW VIEW OF EMPLOYEES
          02 NAME
          02 FIRST-NAME
          02 CITY
        *
        01 #NAME (A20)
        01 #CITY (A20)
        END-DEFINE
        *
        REPEAT
          /*
          INPUT USING MAP 'MAP001'
          /*
          IF #CITY NE ' ' AND #NAME NE ' '
            FIND PERS-VIEW WITH NAME = #NAME AND CITY = #CITY
              IF NO RECORDS FOUND
                REINPUT 'NO ONE BY THIS NAME LIVING IN THIS CITY.'
                        MARK *#CITY
              END-NOREC
              /*
              DISPLAY NOTITLE NAME FIRST-NAME CITY
              /*
            END-FIND
          ELSE
            IF #NAME NE ' '
              FIND PERS-VIEW WITH NAME = #NAME
                IF NO RECORDS FOUND
                  REINPUT 'PLEASE TRY ANOTHER NAME.'
                END-NOREC
                /*
                DISPLAY NOTITLE NAME FIRST-NAME CITY
                /*
              END-FIND
            END-IF
          END-IF
          /*
        END-REPEAT
        END

2. If no program name is displayed in the top line of the editor, at the program editor's command prompt, enter the command `STOW PROG001`.

   Or:
   If the program name PROG001 is displayed in the top line of the editor, at the program editor's command prompt, enter the command `STOW`.

   If required, correct any syntax errors and repeat the `STOW`.

   After the `STOW` completed successfully, the program is stored as a source object and a cataloged object in the current Natural library in the current system file.

3. At the program editor's command prompt, enter the following:

       RUN

   PROG001 is executed and map MAP001 appears.

To check whether MAP001 works as intended

1. Press ENTER without typing in anything.

   The following message is displayed: `PLEASE TYPE IN A NAME`.

2. In the first input field, enter a question mark (?) and press ENTER.

   Help map HELP001 appears.

3. Press ENTER.

   The help map disappears.

4. In the first input field, enter the name `MCKENNA` and press ENTER.

   The following message is displayed: `PLEASE TRY ANOTHER NAME`.

5. Replace `MCKENNA` by `JONES` and press ENTER.

   The program produces the following list:

               NAME              FIRST-NAME              CITY
       -------------------- -------------------- --------------------

       JONES                VIRGINIA             TULSA
       JONES                MARSHA               MOBILE
       JONES                ROBERT               MILWAUKEE
       JONES                LILLY                BEVERLEY HILLS
       JONES                EDWARD               CAMDEN
       JONES                MARTHA               KALAMAZOO
       JONES                LAUREL               BALTIMORE
       JONES                KEVIN                DERBY
       JONES                GREGORY              NOTTINGHAM

6. Press ENTER.

   MAP001 appears.

7. In the first input field of the map, enter the name `JONES` and, in the second input field, enter the name `DUNFERMLINE`.

8. Press ENTER.

   The following message is displayed: `NO ONE BY THIS NAME LIVING IN THIS CITY`.

9. In the first input field of the map, enter the name `JONES` and, in the second input field, enter the name `TULSA`.

10. Press ENTER.

    The program produces the following list:

                NAME              FIRST-NAME              CITY
        -------------------- -------------------- --------------------

        JONES                VIRGINIA             TULSA

11. Press ENTER.

    MAP001 appears.

12. In the first input field, enter a period (.) and press ENTER.

    The editing area of the program editor appears with the source code of PROG001.

You can now proceed with Creating a Map for WRITE and Copying Field Definitions.