Here's the general pattern of a loop in Praat: Now, looking at the first line of the loop. If you forget this step in a long script with several loops, you may have a lot of trouble fixing your mistake. Just like with if statements, WHENEVER YOU START A FOR LOOP, ALWAYS WRITE THE CLOSING ENDFOR RIGHT AWAY, and indent the code it contains. Firstly, it begins with "for" and ends with "endfor". This is a "for" loop, and it's practically the only loop you need (though there are others). Type this in and run it.ĪppendInfoLine: "Day ", day, ": take the metro" Programming is learned by doing, and you are more likely to remember the syntax if you actually practice typing it in, and you will develop your debugging skills when you inevitably make mistakes.Įvery day I take public transit to work. Do not just read along, and do not copy paste, unless you've already typed it in and are having trouble spotting a typo. VERY IMPORTANT: Type these examples in yourself. Some keys to staying sane are to constantly test your assumptions and print to the info window, to spend the extra time writing small test scripts when you're writing a longer script (saving yourself time in the long run), and to develop the skill of breaking a bigger problem into smaller tasks, both when designing code and when solving unexpected behavior. I do have to warn you that along with conditionals, you will make a lot of mistakes until you get very comfortable with loops (and then afterwards too). The whole point of programming is to automate some repetitive task, and we typically do that using loops: you run a series of commands over and over, changing a few values each time. Now we are starting to get to the good stuff: loops.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |