<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<div class="moz-cite-prefix">On 28/01/2014 16:43, Stefan Du Rietz
wrote:<br>
</div>
<blockquote cite="mid:52E7D019.6030708@durietz.se" type="cite">On
2014-01-28 09:54, Adrien Vogt-Schilb wrote:
<br>
--------------------
<br>
<blockquote type="cite">On 28/01/2014 09:41, Stefan Du Rietz
wrote:
<br>
<blockquote type="cite">On 2014-01-27 22:43, Serge Steer wrote:
<br>
--------------------
<br>
<blockquote type="cite">Le 27/01/2014 19:05, Stefan Du Rietz a
écrit :
<br>
<blockquote type="cite"><br>
</blockquote>
Under pause, you cannot modify a variable which is defined
in the
<br>
calling context
<br>
so in such a context args is not a list as you expect but an
empty
<br>
array which is implicitely created
<br>
<br>
To make it work
<br>
you must do
<br>
-1-> args; //makes a local copy of args
<br>
-1->args(1) = null()
<br>
<br>
Serge
<br>
</blockquote>
<br>
What do you mean by "defined in the calling context"?
<br>
I can modify this:
<br>
<br>
-1->isfast
<br>
isfast =
<br>
0. 0.
<br>
-1->isfast(1) = 1
<br>
isfast =
<br>
1. 0.
<br>
<br>
Stefan
<br>
<br>
<br>
</blockquote>
<br>
Stefan, you may want to have a look at
<br>
<a class="moz-txt-link-freetext" href="http://wiki.scilab.org/howto/global%20and%20local%20variables">http://wiki.scilab.org/howto/global%20and%20local%20variables</a>
<br>
This page explains what Serge means i believe.
<br>
<br>
Adrien
<br>
<br>
</blockquote>
Thank you Adrien, but I have had many looks at it ;-)
<br>
<br>
I still don't understand the difference between my variables args
and isfast. They are both defined in the function.
<br>
<br>
args: input values of the function are assigned to the
corresponding local variables of the function (local variables and
scoping 5.)
<br>
<br>
isfast: local variables defined at level_N remain local at that
level. (local variables and scoping 2.).
<br>
<br>
What am I missing? Am I just stupid?
<br>
<br>
Stefan
<br>
</blockquote>
<br>
I believe the local and global variable stuff explains why you are
able to reproduce your bug only under pause, as documented here <a
class="moz-txt-link-freetext"
href="http://wiki.scilab.org/howto/global%20and%20local%20variables">http://wiki.scilab.org/howto/global%20and%20local%20variables</a>
(gosh, the page does not explain that pause and functions behave the
same way... this is probably our problem here)<br>
This means that there is not "strange list error", only a confusing
behaviour of scilab under pause. If i am correct, none of your
functions suddenly stopped working. <br>
Coming back to the original post:<br>
<font color="#3366ff"><br>
-1->args(1) = null();
<br>
args(1) = null();
<br>
!--error 44
<br>
Wrong argument #2.
<br>
<br>
and when I checked:
<br>
-1->typeof(args)
<br>
ans =
<br>
list
<br>
<br>
Can anybody explain that?
<br>
</font><br>
The explanation is that you just created a new pause environment,
where args do no exist yet.<br>
The line <font color="#3366ff">-1->args(1) = null();
</font>(witten just after entering in pause) then behaves exactly
the same way as if you open a new scilab consoloe and write <font
color="#ff0000">args(1) = null()</font><br>
<br>
In other words, you cannot debug your function using pause like
that. In the precise case of your function, one thing that would
work is to pause the function just after entering (before the line
args = varargin;), or to use the solution Serge gave you, that is
replace the lines 8 and 9<br>
<font color="#3333ff">pause<br>
args(1) = null(); </font><br>
with<br>
<font color="#3333ff">pause<br>
args; //makes a local copy of args
in the new pause environment<br>
args(1) = null();</font><br>
<br>
Please make sure you understand that nothing discussed here as
nothing to do with your function, (which i did not read and i bet
serge did not read).<br>
The bug comes from how you use pause to try to debug your function
(and yes, this is very annoying as it prevents to use pause to debug
scilab seamlessly.). <br>
<br>
I'm confused whether this answer your original question, and whether
you have more questions<br>
<br>
Adrien<br>
<br>
</body>
</html>