Call

This instruction is used to call a subroutine executed with its own local variables class.
No value is returned by this instruction. Parameters can be transmitted as values or as references; so that the parameters transmitted by reference can be modified by the subroutine.

Syntax

Call SUBPROGRAM
Call SUBPROGRAM From LIBRARY
Call SUBPROGRAM(ARGUMENT_LIST)
Call SUBPROGRAM(ARGUMENT_LIST) From LIBRARY
Call SUBPROGRAM From =EXPRESSION_LIBRARY
Call SUBPROGRAM(ARGUMENT_LIST) From =EXPRESSION_LIBRARY
Call =EXPRESSION_CALL
Call =EXPRESSION_CALL From LIBRARY
Call =EXPRESSION_CALL With (ARGUMENT_LIST)
Call =EXPRESSION_CALL With (ARGUMENT_LIST) From LIBRARY
Call =EXPRESSION_CALL With (ARGUMENT_LIST) From =EXPRESSION_LIBRARY
Call =EXPRESSION_CALL With (ARGUMENT_LIST) From =EXPRESSION_LIBRARY

Examples

  # Call of a routine that increments a value
  Local Integer I
  I=314 : Call ADD_ONE(I)
  I=314 : Call TRY_TO_ADD_ONE(I)
  I=315 : Call FAIL_TO_ADD_ONE(I)
  # The value of I found here depends on how the parameter has been declared in the routine
  # After the first call, I=315
  # After the second call, I=314
  # The third call will raise an error
  ...

  # Case 1 : the argument is declared as a reference
  Subprog ADD_ONE(J)
  Variable Integer J
    J+=1  : # J is equal to 315, but J is a reference to I in the calling script, so I is equal to 315
    I=316 : # I is a local variable that does not refer to the I variable in the calling script
  End

  # Case 2 : the argument is declared as a value
  Subprog TRY_TO_ADD_ONE(J)
  Value Integer J
    J+=1 : # J is equal to 315, but J is a local copy of I that is not sent back, so I remains equal to 314
  End

  # Case 3 : the argument is declared as a constant reference
  Subprog FAIL_TO_ADD_ONE(J)
  Value Integer J
    J+=1  : # Raises an error : J is read-only
  End


  # Call of a subroutine with parameters in another process
  Local Integer MATRIX(1..10,1..20,1..30)
  ...
  # Only a subarray is transmitted (even if it is sent as a reference)
  Call COMPUTE_SUM(MATRIX(5..6,2..4,1..20),RESULT) FROM MATRIX_LIBRARY
  ...
  # In the MATRIX_LIBRARY script, the arguments are
  Subprog COMPUTE_SUM(MATRIX,RESULT)
  Const Integer MATRIX(,,)
  Variable Integer RESULT
    RESULT=sum(MATRIX)
  End

  # A subprogram that returns the data type of the argument
  Subprog RETURN_TYPE(ARGUMENT,DATA_TYPE)
  Variable Integer DATA_TYPE
    DATA_TYPE=type(ARGUMENT)
  End


  # Example of sub-program with a variable type of argument
  Local Integer DATA_TYPE
  Local Char MY_STRING(20),TEXT(10)
  MY_STRING="abcdefghijklmnopqrst"

  Call RETURN_TYPE(pi,DATA_TYPE,TEXT)          : # Will return 7 (decimal) and "3.14159265"
  Call RETURN_TYPE([1/1/2013],DATA_TYPE,TEXT)  : # Will return 3 (date) and "01/01/2013"
  Call RETURN_TYPE(100,DATA_TYPE,TEXT)         : # Will return 4 (integer) and "100"
  Call RETURN_TYPE("text sent",DATA_TYPE,TEXT) : # Will return 523 (clob) and "text sent"
  Call RETURN_TYPE(MY_STRING,DATA_TYPE,TEXT)   : # Will return 20 (string 10) and "abcdefghij"
  End

  # ARGUMENT has not be declared because it has a variable type
  Subprog RETURN_TYPE(ARGUMENT,DATA_TYPE,TEXT)
  Variable Integer DATA_TYPE
  Variable Char TEXT()
    DATA_TYPE=type(ARGUMENT) : # returns the data type of the argument
    TEXT=num$(ARGUMENT)      : # returns a string representation of the argument regardless of its type
  End

Comments

Associated Errors

Error code Description
10The expression giving the script name does not return a string value.
20The process does not exist.
39The label does not exist.
55Number of dimensions invalid.
69Number of parameters does not correspond.
70Transmission mode incompatible.