The Conditional -write- Command (-writec-)
A very common situation is that of needing to write one of several possible messages on the screen. For example, you might like to pick one of five congratulatory messages to write after receiving a correct response from the student:
The -randu- command, “random on a uniform distribution,” tells TUTOR to pick an integer between 1 and 5 and put it in N. We then use this value of N to do one of five units to write one of five messages. There is a much more compact way of writing this:
The -writec- command is similar to that of a conditional branching command, but the listed elements are pieces of text rather than unit names. Because -write- can be used to display any kind of text (including commas), it is necessary to use a different command name (-writec-) to indicate the conditional form of -write-, whereas in branching statements the commas separating the unit names are enough to tell TUTOR that it is a conditional rather than an unconditional form. (In conversation, “writec” is pronounced “write-see.”)
You can write whole paragraphs with nice left margins, just as with the -write- command:
The elements of text are set off by commas. If N is 3, the student will see a three-line paragraph, since there are no commas at the end of “of” and “so”. If N is -1 or 0, no text will be displayed, since there is no text between the first few commas. Note that “x” is not the fall-through that it is for a unit name in a conditional branching command. Here, “x” is a legitimate piece of text which can be displayed, so the “„” form is the “fall-through”.
If you want commas to appear in some of your text elements, you have a problem, since the commas delimit elements. Consider this:
If N is zero, we will see “How are you”, not “How are you, Bill?” The solution is to use a special character (↕):
Now, if N=0 we will see “How are you, Bill?” While this special character (↕) is required if text elements contain commas, you may prefer to use it always, even when there are no commas. This special character is often called “the writec delimiter”.
The same kinds of embedding of other commands which are permitted by -write- are also permitted with -writec-:
The -writec- is affected by -size- and -rotate- commands, just like -write-.