Method arguments, including
input and output parameters, are passed to SAS Micro Analytic Service
as a com.sas.mas.tksfValues Java object.
tksfValues p = new tksfValues(numArgsTotal, numInputs);
The first parameter
to the tksfValues constructor is the total number of arguments, including
both inputs and outputs. The second parameter specifies the number
of input arguments of the method.
Note: Before calling execute(),
all method arguments, including outputs, must be set on the tksfValues
instance. Output arguments are set by calling the setOut<type>
methods of tksfValues.
Output arguments must
be set for two reasons:
-
DS2 passes output arguments by
reference. Therefore, the correct types must be allocated in order
to receive the output values. Because DS2 follows this pass-by-reference
convention, SAS Micro Analytic Service follows the same convention
regardless of the programming language.
-
SAS Micro Analytic Service supports
method overloading. When overloaded methods are used, the method
signature (list of input and output parameters and their types) is
used to select the correct method to execute. Because a method signature
includes both input and output parameters, the output parameter types
must be set in tksfValues.
In DS2, when two or
more methods in the same package have the same name, those methods
are said to be overloaded. Each module constitutes a separate namespace.
Therefore, two DS2 methods that have the same name, but are in different
packages, are not considered overloaded. Similarly, two C functions
with the same name, but in different C modules, will not have a name
conflict.
Note: The C language does not support
method overloading. Syntax errors occur if two C functions with the
same name exist in the source code of the same C module.
DS2 in_out parameters
are treated strictly as output. This convention is necessary to support
the REST interface, which does not support true in/out arguments.
When you are coding
in DS2 or C, all input arguments must be positioned before any output
arguments. Failure to do so causes your method to malfunction. SAS
Micro Analytic Service might not detect this error because the DS2
compiler does not carry this restriction.
Note: Arrays are always passed
by reference in DS2, regardless of whether the in_out keyword is specified.
However, SAS Micro Analytic Service treats arrays without the in_out
keyword as input and arrays with the in_out keyword as output, as
long as all inputs precede outputs in the method signature.
Incorrect:
method solve(double tempRate, in_out int finalRate, int custId);
Correct:
method solve(double tempRate, int custId, in_out int finalRate);
tksfValues provides
methods for setting and getting arguments, including methods that
enable the use of explicit or implicit argument indices and methods
that support missing values. These methods are described in the sections
that follow.