CheckRhs(minrhs, maxrhs) CheckLhs(minlhs, maxlhs)Function
CheckRhsis used to check that the Scilab function is called with
minrhs <= Rhs <= maxrhs. Function
CheckLhsis used to check that the expected return values are in the range
minlhs <= Lhs <= maxlhs. (Usually one has minlhs=1 since a Scilab function can be always be called with less lhs arguments than expected).
ct(string) are inputs and
lk(integers) are outputs of
GetRhsVar. This function defines the type (
ct) of input variable numbered
k, i.e. the
kth input variable in the calling sequence of the Scilab function. The pair
mk,nkgives the dimensions (number of rows and columns) of variable numbered
kif it is a matrix. If it is a chain
mk*nkis its length.
lkis the adress of variable numbered
kin Scilab internal stack. The type of variable number
ct, should be set to "d", "r", "i" ,"z" or "c" which stands for double, float (real), integer, double complex or character respectively. The interface should call function
GetRhsVarfor each of the rhs variables of the Scilab function with k=1, k=2,..., k=Rhs. Note that if the Scilab argument doesn't match the requested type then Scilab enters an error function and returns from the interface function.
k,ct,&mk,&nkare inputs of
lkis an output of
CreateVar. The parameters are as above. Variable numbered
kis created in Scilab internal stack at adress lk. When calling CreateVar, k must be greater than Rhs i.e. k=Rhs+1, k=Rhs+2, .... If due to memory lack, the argument can't be created, then a Scilab error function is called and the interface function returns.
k,ct,&mk,&nk,&lkare all inputs of
lkis pointer created by a call to a C function. This function is used when a C object was created inside the interfaced function and a Scilab object is to be created using a pointer to this C object.
Once the variables have been processed by GetRhsVar or created by CreateVar, they are given values by calling one or several numerical routine. The call to the numerical routine is done in such a way that each argument of the routine points to the corresponding Scilab variable. Character, integer, real, double and double complex type variables are respectively in the cstk, istk, sstk, stk, zstk Scilab internal stack at the adresses lk's returned by GetRhsVar or CreateVar.
Then they are returned to Scilab as lhs variables. The interface should define how the lhs (output) variables are numbered. This is done by the global variable LhsVar. For instance
LhsVar(1) = 5; LhsVar(2) = 3; LhsVar(3) = 1; LhsVar(4) = 2;means that the Scilab function has at most 4 output parameters which are variables numbered
k= 5, k=3, k=1, k=2respectively.
Error(k) are used
for managing messages and errors.
Other useful functions which can be used are the following.
GetMatrixptr("Aname", &m, &n, &lp);This function reads a matrix in Scilab internal stack.
Anameis a character string, name of a Scilab matrix. Outputs are integers
lp, the entries of the matrix are ordered columnwise.
ReadString("Aname",&n,str)This function reads a string in Scilab internal stack.
nis the length of the string.
The Fortran functions have the same syntax and return logical values.