Scilab Website | Contribute with GitLab | Mailing list archives | ATOMS toolboxes
Scilab Online Help
5.3.1 - Português

Change language to:
English - Français - 日本語 -

Please note that the recommended version of Scilab is 2025.0.0. This page might be outdated.
However, this page did not exist in the previous stable version.

Ajuda Scilab >> API Scilab > Scilab Gateway API > OverLoad

OverLoad

C gateway function which tells Scilab to look for another overloaded function

Calling Sequence

OverLoad(StackPos)

Arguments

StackPos

the position in the Scilab memory of the parameter for which we want to take into account for the overloading process (input argument)

Description

A C gateway function which tells Scilab to look for another overloaded function. Scilab then appends to the name of the function a prefix (like %sp_ if the parameter taken into account is sparse) and look for the overloaded function. You must include stack-c.h to benefit from this function.

Be careful with the Scilab name of the function. Indeed, the current overloading process of Scilab works only on Scilab primitives (Scilab function wrote in C) which must have a Scilab name which is maximum 8 char wide.

WARNING: This API is deprecated from Scilab 5.2.0 and is going to be removed with Scilab 6.0. Please use API Scilab (the new Scilab API).

Examples

In this example, the C interface function takes one input parameters and prints the integer corresponding to the type of the variable sent as parameter in the Scilab console.

#include <stack-c.h>
#include <sciprint.h>

int sci_check_properties_2(char * fname)
{
  int m1,n1,l1;

  CheckRhs(1,1);
  CheckLhs(0,1) ;

  switch(VarType(1)) 
    {
    case sci_matrix: 
      GetRhsVar(1, "d", &m1, &n1, &l1);
      sciprint("1 is a scalar matrix\n");
      break;
    case sci_strings:
      GetRhsVar(1, "c", &m1, &n1, &l1);
      sciprint("1 is a string\n");
      break;
    case sci_sparse:
      sciprint("1 is a sparse trying to overload\n");
      OverLoad(1);
    }

  LhsVar(1) = 0;

  return 0;
}
 </programlisting>

    <para>The builder.sce script look like this:</para>

    <programlisting role = "example"><![CDATA[  
// This is the builder.sce 
// must be run from this directory 

lines(0);

ilib_name  = 'lib_check_properties';

files = ['check_properties.c'];

libs  = [];

table =['chprop2', 'sci_check_properties_2'];

// We must be careful when we choose a scilab function name in case of overloading.
// We Scilab name function must be 8 char max.

ldflags = "";
cflags  = "";
fflags  = "";

ilib_build(ilib_name,table,files,libs,'Makelib',ldflags,cflags,fflags);

And now, an example of use of this new function:

chprop2([1,2,2]);
chprop2('foo');

// overload case 

deff('[]=%sp_chprop2(sp)','disp(''sparse overloaded'')');
chprop2(sparse([1,2,3]));

See Also

  • CheckColumn — C interface function which checks if a parameter send to the C function is a column vector or not
  • CheckDims — C interface function which checks if a parameter send to the C function has the required dimensions
  • CheckRow — C interface function which checks if a parameter send to the C function is a row vector or not
  • CheckScalar — C interface function which checks if a parameter send to the C function is a scalar or not
  • CheckVector — C interface function which checks if a parameter send to the C function is a vector (column or row) or not
  • CheckDimProp — C interface function which checks the comatibility between 2 arguments send to the C function
  • CheckLength — C interface function which checks the length of a vector send as a parameter to the C function
  • CheckSameDims — C interface function which checks if two parameters send to the C function have the same size
  • CheckSquare — C interface function which checks if a parameter send to the C function is a square matrix or not
  • How to check parameters — how to check parameter send to an interface using the C gateway functions
<< NumOpt Scilab Gateway API Rhs >>

Copyright (c) 2022-2024 (Dassault Systèmes)
Copyright (c) 2017-2022 (ESI Group)
Copyright (c) 2011-2017 (Scilab Enterprises)
Copyright (c) 1989-2012 (INRIA)
Copyright (c) 1989-2007 (ENPC)
with contributors
Last updated:
Thu Mar 03 11:00:37 CET 2011