Hello,
Is there a way to debug the code that i’m missing? I am writing the code, and will get the orange tag at the top of the screen and I know if have a mistake. However, i’m used to being able to run the code one line at a time and check each variable’s value. But I can’t do it for this.
for example, i’m writing a reporter, but since there is an error, I’m having trouble debugging it.
any help is appreicated.
thank you.
Unfortunately, we don’t currently have a line by line debugger. One thing you can do instead is print values at various points in your reporter to check if they do what you expect. If you’re still having trouble figuring out the error, feel free to post our code or upload your model and I or someone else will be happy to help.
Thank you, I appreciate the feedback. But how can I even use the print statement method if the model won’t run? Once I get the orange line error message in the code tab, I can’t hit the GO button to run the model to print the variable to see what it is. This is where i’m stuck. Is there a work around to this? I think allot of these are syntax errors, as I just started working in netlogo this semester. Thank you.
For syntax errors, the primitive where the error occurs should get highlighted as well (hopefully with a helpful error message) and then you can look up that primitive in the dictionary and see what is wrong with the syntax. Again, for any specific error, feel free to post in the forum if you can’t figure it out, maybe in the New to NetLogo category.
While there are still syntax errors, it makes no sense running the code.
However, after solving the syntax errors – or commenting them out (trick) – there is a way to run code line-by-line. It is not as nice as a full-fledged debugger, but it has helped me and my students for finding subtle problems in NetLogo code:
At the level of the observer, you can type one line at a time in the input line of the Command Center.
At the level of an individual agent, you can open a turtle/patch/link monitor on that agent (right-click in the world display of the Interface tab), and then type one line at a time in its command line (at the bottom of the monitor).
For inspecting global variables, open the Globals monitor from the Tools menu.
For inspecting agent-own variables, you can see any effects immediately in the agent monitor itself.
Of course, stepping into a procedure/reporter is not as easy as in a debugger. But still you can continue typing one line at a time in the respective command line.
Even for pin-pointing syntax errors, it can help typing just the one offending line into the Command Center.
1 Like