Call Statement

Calls a subroutine. Not available in expressions.

Syntax

Call subroutine [ ( argument [ , argument ] ... ) ]

argument is a variable, expression, or constant that you want to pass to the subroutine. Multiple arguments must be separated by commas.

Remarks

Call transfers program control from the main program to a compiled external subroutine. Use a Return statement to return control to the main program.

The number of arguments specified in a Call statement must match the number of arguments specified in the Subroutine statement that identifies the subroutine.

Constants are passed by value; variables are passed by reference. If you want to pass variables by value, enclose them in parentheses.

Note: If you pass variables by value, any change to the variable in the subroutine does not affect the value of the variable in the main program. If you pass variables by reference, any change to the variable in the subroutine also affects the main program.

Example

This example shows how to call a before/after routine named MyRoutineB from within another routine called MyRoutineA:

Subroutine MyRoutineA(InputArg, ErrorCode)
   ErrorCode = 0         ;* set local error code
   * When calling a user-written routine that is held in the 
   * DataStage repository, you must add a "DSU." Prefix.
   * Be careful to supply another variable for the called
   * routine's 2nd argument so as to keep separate from our    
   * own.
   Call DSU.MyRoutineB("First argument", ErrorCodeB)
   If ErrorCodeB <> 0 Then
      ... ;* called routine failed - take action
   Endif
Return