[scilab-Users] feval an external function

Peter von Niederhaeusern pvonnied at gmail.com
Mon Jul 12 15:36:19 CEST 2010


Thank you all for your help.

I did choose the solution proposed by Jérôme (and it seems to work),
as the function 'bar' is not directly passed as a "function pointer"
to the function 'foo'
but as a string variable which is assigned the function name (like a
parameter for a function).

I might be missing a point but it works and the hint from Mathieu is
an important one nevertheless.

Merci et salutations
Peter

On Sat, Jul 10, 2010 at 1:08 PM, Mathieu Dubois <mathieu.dubois at limsi.fr> wrote:
> Hello Peter,
>>
>> In the main script I call a function 'foo' (which is made known to the
>> main script by exec('foo.sci'))
>> which takes another function 'bar' and some arguments as its arguments.
>>
>> Inside the body of 'foo' the function 'bar' is evaluated by
>> 'feval(arguments,'bar')'...
>>
>
> Are you sure that this what you want to do? Under scilab feval is used to
> evaluate an external function on several arguments (see help page). This is
> different than matlab© function feval.
>>
>> Unfortunately the interpreter cannot find the function 'bar' (although
>> that function is also made known
>> to the main script). Error message: feval: entry point bar not found
>> in predefined tables or link table.
>>
>> Is there a way to execute the function 'bar' inside the function 'foo'?
>>
>
> If I understand your problem, you want to pass a function (bar) as an
> argument to another function (foo) and evaluate it, right?
>
> The good new is that scilab functions are variables so you can pass the
> function bar as an argument (without quotes). Let's say that the argument
> name is bar_function. Then you can simply write (inside foo)
>  bar_function(args).
>
> See chapter 6 of "An Introduction to Scilab from a Matlab User's Point of
> View" by Eike Rietsch on scilab website
> (http://www.scilab.org/en/support/documentation/community).
>
> I have attached a dummy example (where the function to call is called bars
> to avoid erasing the predefined bar)
>
> HTH,
> Mathieu
>



More information about the users mailing list