
WriteInfoLine: "The value of c is ", c, "."Ĭan you figure out what the Info will report? If you think it will report The value of c is 6.2., then you are correct: after the first line, b contains the value 3.1 after the second line, the value of c is therefore 6.2, and nothing more after line 3, the value of b has changed to 5.8, but the value of c hasn't changed and is still 6.2. The Info window thus reports The value of b is 3.1, and the value of c is 6.2.Īfter these explanations, consider the following script: Praat evaluates this formula and stores the result (namely the value 6.2) into the variable c, which will then contain nothing else than the value 6.2. Praat looks up the value of b (which is 3.1), so that it knows that the formula actually means 3.1 * 2. In the second line, the formula b * 2 first has to be evaluated. WriteInfoLine: "The value of b is ", b, ", and the value of c is ", c, "." the value 6.2 is subsequently stored in the variable b.Īfter line 1 has been executed, the variable b just contains the value 6.2, nothing more the variable b doesn't remember that that value has been computed by multiplying 3.1 with 2.įormulas can contain more things than numbers: they can also contain other variables: its value is computed), and the result is 6.2.Ģ. This works because Praat handles the first line in the following way:ġ.

In an assignment, the part to the right of the "becomes" sign (the "=" sign) doesn't have to be a number it can be any formula that evaluates to a number. Or the family 3.1 moves from the house, and the family called 5.8 moves in. It's like taking the 3.1 out of the box and putting the 5.8 in its stead. The first line puts the value 3.1 there, but the second line replaces it with 5.8. You will see that b ends up having the value 5.8. into the Info window, as you are invited to verify.Ī variable is called a variable because it is variable, i.e. To see what value a variable contains (what's in the box, or who lives in the house), you can use the writeInfoLine function: Or you can regard it as any other storage location. Or you can regard a variable as a house: the house is called b and now the family "3.1" is living there. You can regard a variable as a box: you put the value 3.1 into the box named b. What this means is that after this statement, the memory location b contains the numeric value (number) 3.1. We read this statement aloud as "b becomes 3.1". This statement is called as assignment, i.e., you assign the value 3.1 to the variable b.

In any general procedural programming language you can work with variables, which are places in your computer's memory where you can store a number or anything else.įor instance, you could put the number 3.1 into the variable b in the following way:
