5 A task with two actions

Let us make the task SUMS able to accept two different commands. SUMS.IFL contains

  interface SUMS
     parameter VALUE
        type ’_REAL’
     endparameter
     action SQUARE
        obey needs VALUE
        endobey
     endaction
     action ADD
        obey needs VALUE
        endobey
     endaction
  endinterface

and SUMS.FOR contains

        SUBROUTINE SUMS ( STATUS )
        IMPLICIT NONE
        INCLUDE ’SAE_PAR’
        INCLUDE ’ACT_ERR’
        INTEGER STATUS
        REAL VALUE
        CHARACTER*(PAR__SZNAM) NAME
  
        IF ( STATUS .NE. SAI__OK ) RETURN
        CALL TASK_GET_NAME ( NAME, STATUS )
        IF ( NAME .EQ. ’SQUARE’ ) THEN
           CALL PAR_GET0R ( ’VALUE’, VALUE, STATUS )
           CALL MSG_SETR ( ’ANS’, VALUE**2 )
           CALL MSG_OUT ( ’ ’, ’answer is = ^ANS’, STATUS )
        ELSE IF ( NAME .EQ. ’ADD’ ) THEN
           CALL PAR_GET0R ( ’VALUE’, VALUE, STATUS )
           CALL MSG_SETR ( ’ANS’, VALUE+VALUE )
           CALL MSG_OUT ( ’ ’, ’answer is = ^ANS’, STATUS )
        ENDIF
        END

As above, you can issue the ICL command

  ICL> send sums obey square

and you will be prompted for VALUE. Thereafter, that same value of VALUE will be used, even if you

  ICL> send sums obey add

However, notice that the interface file has now been changed to specify that VALUE is NEEDed by the actions. This means that you can

  ICL> send sums obey add 42

and the value 42 is put into the parameter by the fixed-part before your application is called.