[scilab-Users] debugging and pause
Antoine Monmayrant
antoine.monmayrant at laas.fr
Mon Nov 29 09:11:06 CET 2010
Le 29/11/2010 07:45, MS a écrit :
> Can someone please give me step by step instructions for how to find out what
> the value of a particular variable inside a user-defined function is? I have
> tried using disp, pause, mprintf, print. Perhaps I am not using these things
> properly. I am running scilab 5.2.2, but I am willing to run an earlier
> version if that would help. Thank you.
>
The idea is quite simple:
- go to the source of your function;
- add a pause somewhere (after the variable you want to test has been
modified). I usually add a pause just before the line where I have an
error or just before the end of the function if I don't get any error
while running the function.
- re-evaluate your function (so that scilab is aware of the code
change). You can just "exec" the file that contain the function or copy
paste its code into the console.
- call your function. The pause should give you a special prompt:
"-1->". While you have this prompt, you can access all the variables
that are defined within the scope of your function and above the "pause"
you have inserted. Once you are done press "resume" to go on with the
execution of your function.
Here is an example of a function foo() with no argument that returns 3*3:
function x2=foo()
temp=3;
x2=temp*temp;
endfunction
Out of the function, I cannot access "temp" to test its value. To do so,
I change "foo()":
function x2=foo()
temp=3;
x2=temp*temp;
pause // now I-1-> gives me access to the inner variables of foo()
endfunction
Now, If I re-evaluate this new code and run the function, I can test temp:
foo()
temp
temp==3
resume
Hope it helps
Antoine
More information about the users
mailing list