Re: [Scilab-users] Strange list error

2014-01-28 Thread Stefan Du Rietz

On 2014-01-27 22:43, Serge Steer wrote:


Le 27/01/2014 19:05, Stefan Du Rietz a écrit :

Hello Paul,
after trying like a maniac ;-) I finally managed to reproduce it!

The error shows up only when you run the command from the command
window after a pause in the attached function testlisterror.sci.

--testlisterror(pnonfast,nonfast)
-1-args(1) = null()
args(1) = null()
 !--error 44
Wrong argument #2.

Without the pause it works OK.

Regards
Stefan

Under pause, you cannot modify a variable which is defined in the
calling context
so in such a context args is not a list as you expect but an empty
array which is implicitely created

To make it work
you must do
-1- args; //makes a local copy of args
-1-args(1) = null()

Serge


What do you mean by defined in the calling context?
I can modify this:

-1-isfast
 isfast  =
0.0.
-1-isfast(1) = 1
 isfast  =
1.0.

Stefan


___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] Strange list error

2014-01-28 Thread Adrien Vogt-Schilb

On 28/01/2014 09:41, Stefan Du Rietz wrote:

On 2014-01-27 22:43, Serge Steer wrote:


Le 27/01/2014 19:05, Stefan Du Rietz a écrit :

Hello Paul,
after trying like a maniac ;-) I finally managed to reproduce it!

The error shows up only when you run the command from the command
window after a pause in the attached function testlisterror.sci.

--testlisterror(pnonfast,nonfast)
-1-args(1) = null()
args(1) = null()
 !--error 44
Wrong argument #2.

Without the pause it works OK.

Regards
Stefan

Under pause, you cannot modify a variable which is defined in the
calling context
so in such a context args is not a list as you expect but an empty
array which is implicitely created

To make it work
you must do
-1- args; //makes a local copy of args
-1-args(1) = null()

Serge


What do you mean by defined in the calling context?
I can modify this:

-1-isfast
 isfast  =
0.0.
-1-isfast(1) = 1
 isfast  =
1.0.

Stefan




Stefan, you may want to have a look at 
http://wiki.scilab.org/howto/global%20and%20local%20variables

This page explains what Serge means i believe.

Adrien






___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users



--
Adrien Vogt-Schilb
PhD Student (Cired)

___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] Strange list error

2014-01-28 Thread Adrien Vogt-Schilb

On 28/01/2014 16:43, Stefan Du Rietz wrote:

On 2014-01-28 09:54, Adrien Vogt-Schilb wrote:


On 28/01/2014 09:41, Stefan Du Rietz wrote:

On 2014-01-27 22:43, Serge Steer wrote:


Le 27/01/2014 19:05, Stefan Du Rietz a écrit :



Under pause, you cannot modify a variable which is defined in the
calling context
so in such a context args is not a list as you expect but an empty
array which is implicitely created

To make it work
you must do
-1- args; //makes a local copy of args
-1-args(1) = null()

Serge


What do you mean by defined in the calling context?
I can modify this:

-1-isfast
 isfast  =
0.0.
-1-isfast(1) = 1
 isfast  =
1.0.

Stefan




Stefan, you may want to have a look at
http://wiki.scilab.org/howto/global%20and%20local%20variables
This page explains what Serge means i believe.

Adrien


Thank you Adrien, but I have had many looks at it ;-)

I still don't understand the difference between my variables args and 
isfast. They are both defined in the function.


args: input values of the function are assigned to the corresponding 
local variables of the function (local variables and scoping 5.)


isfast: local variables defined at level_N remain local at that level. 
(local variables and scoping 2.).


What am I missing? Am I just stupid?

Stefan


I believe the local and global variable stuff explains why you are able 
to reproduce your bug only under pause, as documented here 
http://wiki.scilab.org/howto/global%20and%20local%20variables (gosh, the 
page does not explain that pause and functions behave the same way... 
this is probably our problem here)
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.

Coming back to the original post:

-1-args(1) = null();
args(1) = null();
 !--error 44
Wrong argument #2.

and when I checked:
-1-typeof(args)
 ans  =
 list

Can anybody explain that?

The explanation is that you just created a new pause environment, where 
args do no exist yet.
 The line -1-args(1) = null(); (witten just after entering in pause) 
then behaves exactly the same way as if you open a new scilab consoloe 
and write args(1) = null()


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

pause
args(1) = null();
with
pause
args; //makes a local copy of args in the new pause environment
args(1) = null();

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).
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.).


I'm confused whether this answer your original question, and whether you 
have more questions


Adrien

___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] Strange list error

2014-01-27 Thread Stefan Du Rietz

Hello Paul,
after trying like a maniac ;-) I finally managed to reproduce it!

The error shows up only when you run the command from the command 
window after a pause in the attached function testlisterror.sci.


--testlisterror(pnonfast,nonfast)
-1-args(1) = null()
args(1) = null()
 !--error 44
Wrong argument #2.

Without the pause it works OK.

Regards
Stefan


On 2014-01-27 08:47, Paul Bignier wrote:



Hello Stefan,

What do you mean by suddenly stopped working? Did you switch Scilab
versions?

Could you provide us the failing test case?
When I type
 args = list(); args(1)=null()
it runs smooth.

Regards,
Paul


On 01/25/2014 09:07 PM, Stefan Du Rietz wrote:

I found out what the error was: I had a line

  if exists(bolus) then

that became true when I had this variable in the workspace, which I
never had before.

I changed it to

  if exists(bolus, l) then

and it worked again.

But I still wonder: why the error 44?

Stefan

On 2014-01-25 18:32, Stefan Du Rietz wrote:


Hi all,
one of my functions suddenly stopped working. During my effort to find
the error by running the commands from the command window, I
experienced this:

-1-args(1) = null();
args(1) = null();
  !--error 44
Wrong argument #2.

and when I checked:
-1-typeof(args)
  ans  =
  list

Can anybody explain that?

Regards
Stefan
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users



___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users






testlisterror.sci
Description: application/scilab
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] Strange list error

2014-01-27 Thread Stefan Du Rietz

PS
--testlisterror(pnonfast,nonfast)

works OK also after resume twice.

/Stefan

On 2014-01-27 19:05, Stefan Du Rietz wrote:


Hello Paul,
after trying like a maniac ;-) I finally managed to reproduce it!

The error shows up only when you run the command from the command
window after a pause in the attached function testlisterror.sci.

--testlisterror(pnonfast,nonfast)
-1-args(1) = null()
args(1) = null()
  !--error 44
Wrong argument #2.

Without the pause it works OK.

Regards
Stefan


On 2014-01-27 08:47, Paul Bignier wrote:



Hello Stefan,

What do you mean by suddenly stopped working? Did you switch Scilab
versions?

Could you provide us the failing test case?
When I type
 args = list(); args(1)=null()
it runs smooth.

Regards,
Paul


On 01/25/2014 09:07 PM, Stefan Du Rietz wrote:

I found out what the error was: I had a line

  if exists(bolus) then

that became true when I had this variable in the workspace, which I
never had before.

I changed it to

  if exists(bolus, l) then

and it worked again.

But I still wonder: why the error 44?

Stefan

On 2014-01-25 18:32, Stefan Du Rietz wrote:


Hi all,
one of my functions suddenly stopped working. During my effort to
find
the error by running the commands from the command window, I
experienced this:

-1-args(1) = null();
args(1) = null();
  !--error 44
Wrong argument #2.

and when I checked:
-1-typeof(args)
  ans  =
  list

Can anybody explain that?

Regards
Stefan
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users



___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users






___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users



___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] Strange list error

2014-01-27 Thread Serge Steer

Le 27/01/2014 19:05, Stefan Du Rietz a écrit :

Hello Paul,
after trying like a maniac ;-) I finally managed to reproduce it!

The error shows up only when you run the command from the command 
window after a pause in the attached function testlisterror.sci.


--testlisterror(pnonfast,nonfast)
-1-args(1) = null()
args(1) = null()
 !--error 44
Wrong argument #2.

Without the pause it works OK.

Regards
Stefan
Under pause, you cannot modify a variable which is defined in the 
calling context
so in such a context args is not a list as you expect but an empty array 
which is implicitely created


To make it work
you must do
-1- args; //makes a local copy of args
-1-args(1) = null()

Serge
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] Strange list error

2014-01-26 Thread Paul Bignier


Hello Stefan,

What do you mean by suddenly stopped working? Did you switch Scilab 
versions?


Could you provide us the failing test case?
When I type
args = list(); args(1)=null()
it runs smooth.

Regards,
Paul


On 01/25/2014 09:07 PM, Stefan Du Rietz wrote:

I found out what the error was: I had a line

  if exists(bolus) then

that became true when I had this variable in the workspace, which I 
never had before.


I changed it to

  if exists(bolus, l) then

and it worked again.

But I still wonder: why the error 44?

Stefan

On 2014-01-25 18:32, Stefan Du Rietz wrote:


Hi all,
one of my functions suddenly stopped working. During my effort to find
the error by running the commands from the command window, I
experienced this:

-1-args(1) = null();
args(1) = null();
  !--error 44
Wrong argument #2.

and when I checked:
-1-typeof(args)
  ans  =
  list

Can anybody explain that?

Regards
Stefan
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users



___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


--
Paul BIGNIER
Scilab Engineer  Xcos Developer
---
Scilab Enterprises
143bis rue Yves Le Coz - 78000 Versailles, France
Phone: +33.1.80.77.04.69
http://www.scilab-enterprises.com

___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


[Scilab-users] Strange list error

2014-01-25 Thread Stefan Du Rietz

Hi all,
one of my functions suddenly stopped working. During my effort to find 
the error by running the commands from the command window, I 
experienced this:


-1-args(1) = null();
args(1) = null();
 !--error 44
Wrong argument #2.

and when I checked:
-1-typeof(args)
 ans  =
 list

Can anybody explain that?

Regards
Stefan
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] Strange list error

2014-01-25 Thread Stefan Du Rietz

I found out what the error was: I had a line

  if exists(bolus) then

that became true when I had this variable in the workspace, which I 
never had before.


I changed it to

  if exists(bolus, l) then

and it worked again.

But I still wonder: why the error 44?

Stefan

On 2014-01-25 18:32, Stefan Du Rietz wrote:


Hi all,
one of my functions suddenly stopped working. During my effort to find
the error by running the commands from the command window, I
experienced this:

-1-args(1) = null();
args(1) = null();
  !--error 44
Wrong argument #2.

and when I checked:
-1-typeof(args)
  ans  =
  list

Can anybody explain that?

Regards
Stefan
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users



___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users