<html><head><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">Dear Frederic<div><br></div><div>Please apologise the belated reply, I was on holidays.</div><div><br></div><div>Anyway, you can also do that in Python using *args parameters, which are basically placeholder for a variable number of arguments. In Python, the same thing would look as follows:</div><div><br></div><div><br></div><div><div>## function MyPoly</div><div><br></div><div>## input 0, constant, 'deg'</div><div>## input 1, inactive, 'a0'</div><div><br></div><div>def MyPoly_check(pNumber, *a):</div><div>    if pNumber == 1:    # if a[0] has changed</div><div>        if a[0] < 1 or a[0] > 100:</div><div>            return 2        # reject parameter change</div><div>        pf.GetFunctionObject(function = '').nrParams = a[0] + 1</div><div>        for i in range(0, int(a[0])+ 1):</div><div>            pf.GetParameterObject(parameter = i+1).name = 'a' + str(i)</div><div>        return 0            # update parameter window</div><div>    return 1                # return 1 if the parameter is fine</div><div><br></div><div>def MyPoly(x, deg, *a):</div><div>    y = 0</div><div>    for i in range(0, int(deg)):</div><div>        y = x * y + a[i]</div><div>    return y</div><div><br></div></div><div><br></div><div><br></div><div>Hope this helps</div><div><br></div><div>Kurt Sutter</div><div>QuantumSoft</div><div><br></div><div><br><div><div>On 14 Jul 2014, at 9:09, BOURDAROT Frederic 136372 <<a href="mailto:frederic.bourdarot@cea.fr">frederic.bourdarot@cea.fr</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div fpstyle="1" ocsi="0" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div style="direction: ltr; font-family: Tahoma; font-size: 10pt;"><span class="Apple-style-span" style="font-family: Times; font-size: 12px;"><pre>Dear all,</pre><pre>I wanted to do the same thing in python but I do not manage. The function check in python needs as parameters the 'ai' parameters, then it becomes difficult to make it dynamical? Do you have a solution or an exemple for this?</pre><pre>Best regards</pre><pre>Frederic Bourdarot</pre><pre><br></pre><pre>Andrew

Yes, you can do that. Basically, you call SetFunctionProperties for  
nrParameters in Check. Here is an example, which basically sets the  
number of parameters to the value you enter in a[1].


function MyPoly;

  var i;

function Check;
begin
        if pNumber = 1 then                             // if a[1] has changed
                if (a[1] < 1) or (a[1] > 100) then
                        Check := bad
                else
                begin
                        SetFunctionProperties(function '', nrParams a[1]+1);
                        Check := update;                        // redraw the parameter window
                end;
end;

begin
        y := 0;
        for i := 1 to a[1] do
                y := x*y + a[i+1];
end;
                
        
You can also set the names of the parameters using  
SetParameterProperties,

Good luck

Kurt

</pre></span><div><span class="Apple-style-span" style="border-collapse: separate; font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; border-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-stroke-width: 0px; font-size: 12px;"><span class="Apple-style-span" style="border-collapse: separate; font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; border-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-stroke-width: 0px; font-size: inherit;"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><span class="Apple-style-span" style="border-collapse: separate; font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; border-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-stroke-width: 0px; font-size: inherit;"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div>Frédéric Bourdarot</div><div>CEA-Grenoble</div><div>INAC/SPSMS/MDN-C5-410</div><div>17, rue des martyrs</div><div>38054 GRENOBLE CEDEX 9</div><div>France</div><div>Tel. +33 438784126</div><div><a href="mailto:frederic.bourdarot@cea.fr">frederic.bourdarot@cea.fr</a></div><div><br></div></div></span><br class="Apple-interchange-newline"></div></span><br class="Apple-interchange-newline"></span><br class="Apple-interchange-newline"></div></div>_______________________________________________<br>proFit-list mailing list<br><a href="mailto:proFit-list@quantum-soft.com">proFit-list@quantum-soft.com</a><br><a href="http://quantum-soft.com/mailman/listinfo/profit-list_quantum-soft.com">http://quantum-soft.com/mailman/listinfo/profit-list_quantum-soft.com</a></div></blockquote></div><br></div></body></html>