This tutorial introduces you to Python, the computer language used to write scripts in Vizard.
To do this tutorial, be sure to having Vizard running side-by-side so that you can try every one of the examples as you go along. This is the best way to learn!
When you write a script, you are writing a list of directions for Vizard to execute. Vizard will go through your script and do everything you tell it to do. The trick is that you need to give your orders in a language that Vizard understands. That language is Python, a common language in the programming world.
Let's write a short script using Python. Make a new script by selecting File > New Vizard File from the menu:
These statements create new variables and then print those variables. Now run the script and save it. Give it a simple name and save it anywhere convenient. Be sure to avoid using anything other than letters and numbers in your script names.
Look at the bottom of your screen and you should see your printout in the input/output window.
A variable can also be an array of other variables. For example, add the following lines to your script and run it again.
Notice that all three values pop up together in an array surrounded by brackets. In the Python language, each element of an array is identified by its position within that array, starting with position 0. So, for example, our array barn has three elements inside of it. The variable cows is the 0th element, pigs is the 1st element, and beasts is the 2nd element. To refer to an element in the array, type the name of that array and then type the element's position in the array between brackets (for example, barn[0] refers to cows).
Add the following lines:
Now run the program again and check out the interactive window.
So far we've seen how the Interactive Window is used to display Python output. It can also be used to test Python logic. Just type your code in the command line at the bottom of the window and Vizard will process the lines one at a time. So, for example, you can run some of the lines from the beginning of this section: