HP 3000 Manuals

CALL [ HP Business BASIC/XL Reference Manual ] MPE/iX 5.0 Documentation


HP Business BASIC/XL Reference Manual

CALL 

The CALL statement transfers control from the program unit that the
statement occurs in to a specified subprogram.  The subprogram that
control is transferred to must be defined in the program or a run-time
error occurs.

The CALL statement can also transfer control to a user-defined multi-line
function.  When used in this manner, the function is actually called as a
subprogram.  The value returned by the function is discarded.

Syntax 

CALL sub_name [(a_param [, a_param]...)]

Parameters 

sub_name         Subprogram that control is transferred to.

a_param          Actual parameter - a value, a variable or an expression,
                 This parameter has a value of the appropriate type to be
                 assigned to the corresponding formal parameter in the
                 SUB statement that begins the subprogram or multi-line
                 function sub_name.

                 The CALL statement assigns the values of the actual
                 parameters to the corresponding formal parameters and
                 transfers control to the subprogram.

Execution of a SUBEXIT or SUBEND statement in the subprogram returns
control to the statement following the CALL statement provided there are
no pending softkey interrupt requests.

Example 

      10 READ A,B$
      15 DATA 1,"Sample"
      20 CALL Subrtn(A,B$)                 !Control goes to line 100
      30 PRINT "Done"
      99 END
     100 SUBPROGRAM Subrtn(Number,String$)
     110   IF Number<1 THEN SUBEXIT
     120   FOR I=1 TO Number
     130     PRINT RPT$(String$,Number)
     140   NEXT I
     150 SUBEND                            !Returns control to line 30

If a program has more than one subunit with the same name, the CALL
statement calls the first one that it finds.  The following is the search
order:

   1.  Single-line function
   2.  Local external or intrinsic function
   3.  Internal multi-line function (one defined by the program)
   4.  Global external or intrinsic subunit

If the program is using softkey handling, the program checks for the key
after the subend statement, but before execution of the next main program
line.  Thus, control can not go to the next line following the CALL, but
to a line specified by an ON KEY statement.



MPE/iX 5.0 Documentation