octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: passing parameters to dynamically-linked functions


From: John W. Eaton
Subject: Re: passing parameters to dynamically-linked functions
Date: Wed, 06 Aug 2008 10:13:26 -0400

On  6-Aug-2008, Thomas L. Scofield wrote:

| 
| What I chose to do was put all the optional parameters in a cell  
| array (do that in the .m file) and pass that along to the dynamically  
| linked file.  That's probably unnecessary work, but I got more  
| comfortable with the Octave API in the process.  One thing I did not  
| learn how to do is access a 2D cell array from within the dynamically  
| linked function.
| 
|    std::string target = args (0).string_value ();
|    Cell c = args (1).cell_value ();
|    octave_idx_type numswitches = c.length ();
|    octave_idx_type i = 0;
|    while (i < c.nelem ()/2 && target.compare (c.elem 
| (2*i).string_value ())) i++;
| 
| seems to work fine (I've packed both the option itself, say  
| "Quality", along with its setting, say 75, into the cell array one  
| right after the other), but things did not seem to work when I had  
| them side-by-side in a 2D array.  I had some other bugs along the  
| way, so perhaps I ought to try it again.
| 
| At any rate, I was mainly concerned with whether there was some  
| standard way to pass parameters like these along, and if there was  
| wanted to follow the convention.

If you are doing something like this:

  function fcn (..., varargin)
    ...
   parameter_value_pairs = ... some subset of varargin, presumably ...
    __fcn_internal__ (parameter_value_pairs);

then I'd suggest making __fcn_internal__ accept the parameter/value
pairs in the same format as the main function (i.e., a list of
parameters, not grouped as a cell array).

jwe


reply via email to

[Prev in Thread] Current Thread [Next in Thread]