

Variables are where the true power and flexibility of programming come to play. You could have written appendInfoLine: 3 + 8, but that would be short-sighted. Here we assign two variables, add them up, and print the result to the Info Window.
PRAAT SHORTCUTS SERIES
You abstract away from a specific number and just have an entity that represents a number, which can be changed and reused in a series of commands, no matter what it's value is: We can treat this variable just like a number, make calculations with it, change its value, rinse and repeat. Who cares? Why are we talking about variables? Well, VARIABLES ARE INCREDIBLY USEFUL AND ARE BASICALLY THE WHOLE POINT OF PROGRAMMING. We'll talk more about this in the next section. The dollar sign at the end of a variable name is legal, but it has a special meaning in Praat. Which of these are legal variable names in Praat, and why?ġ. You should always stick to one naming convention throughout a script to simplify your life.


I personally prefer camel case because I find it easier to type, but it really doesn't matter. You can either use underscores instead of spaces, or use what's known as camel case, where every subsequent word begins with a capital letter: In order to make variable names more readable there are two common practices used to make up for the lack of spaces. Those of us used to a Roman script have a hard time reading words without spaces (not a problem for you, Thailand!!! Whaddup China!!!). Variables are case sensitive (rollsRoyce is not the same variable as rollsroyce). It cannot contain spaces or other "weird" characters like accents or pound signs or the like. Here are the rules for variable names in Praat (hopefully I haven't left anything out):Ī variable can be composed of a combination of letters and numbers, but Praat requires that it start with a lowercase letter. Check out the error message, and be happy that you understand it. Open a new scripting window, type "Number of kids = 2" (without the quotes), and run it. Short so I won't get mad about typing it a bunch of times and am less likely to type it wrong and meaningful so I won't have trouble remembering what it means when I come back to it a few weeks later.īut why didn't I just write "Number of kids = 2"? Besides being long, this would cause an error and Praat would not finish the script, because it has restrictions on what a variable name can look like. I've chosen a name that is short and meaningful. Hopefully it's easy to guess that this variable represents "number of kids". This isn't really required, but is considered good style and supposedly improves readability of your code.
