When you are writing a script in Vizard you should be as precise as possible. When a situation calls for brackets, make sure you use brackets. When a situation calls for indentation, make sure you use tabs. And when you refer to a variable, make sure you use the same name every time.
Let's create an error in our script and see how Vizard responds. Add the following line to your script and run the script:
Your error should read in the output window:
Traceback (most recent call last):
File "<string>", line 11, in ?
File "scences.py", line 20, in ?
print ostrich
NameError: name 'ostrich' is not defined
This line produced an error because we don't have a variable ostrich defined in our script. Vizard identifies the error line by highlighting it in line 20. It also gives you a description of the problem. Oftentimes, this printout gives you a line number for the problem. If you want to find a specific line number, choose View > Line Number.
Another useful tool in writing scripts is commenting out segments of code. Placing a '#' symbol in front of a line of code tells Vizard not to run that line. For example, place a '#' symbol in front of the line we just added and run the script:
We did not get an error this time because Vizard did not read the line. Commenting out is a good way to include documentation within your scripts. To comment out several lines, just highlight those lines and choose Edit > Comment Region . Alternatively, you can use the keyboard shortcut by highlighting the lines and pressing Alt + 3.
As you will see in the following pages of this tutorial, indentation is an important part of writing scripts. For Vizard to understand the indentation the whitespace must be consistent, using either tabs or spaces. Tabs are recommended and automatically inserted in most cases. For example, when the enter key is pressed after a function definition, a tab is inserted in the new line.
So when you are completing this tutorial and your script is using indentation, choose View > Whitespace or View > Indentation Guide. These will reveal where your tabs are and show you how your code is lining up. To convert mixed whitespace to tabs, highlight the code and choose Edit > Tabify Region.