Previous Topic: SubprogramsNext Topic: Passing Data to a Subprogram


Calling a Subprogram

A CALL statement passes control from a CA Ideal program to a subprogram, and, optionally, passes data (in the form of input or update data items) between the two. After the called program terminates, control is returned to the calling program at the next sequential statement in the calling procedure.

In the following example, the MAINMENU panel is transmitted and then, depending on the selection entered, one of the update programs is invoked. When the update program terminates, control returns to the NOTIFY statement in the calling program.

LOOP
    TRANSMIT MAINMENU
  UNTIL $PF3
    SELECT FIRST ACTION
       WHEN SELECTION='1'
          CALL CUSTUPDT
          NOTIFY 'Customer updates completed.  Press PF3 to quit.'
       WHEN SELECTION='2'
          CALL ORDUPDAT
          NOTIFY 'Order updates completed.  Press PF3 to quit.'
       WHEN SELECTION='3'
          CALL INVENUPD
          NOTIFY 'Inventory updates completed.  Press PF3 to quit.'
       WHEN OTHER
          NOTIFY 'Select option 1, 2, or 3, or press PF3 to quit.'
    ENDSEL
ENDLOOP