We have learned how to calculate and how to store results in variables. How do we show these results on the screen? Suppose we perform this calculation:
How do we later show the value of y? Assume we have defined y. Perhaps we could use this:
No, that won't work; that will just put the letter “y” on the screen. The -write- command is basically a device for displaying non-varying text, not for showing the value contained in a variable. We need another command:
This will show the value of y in an appropriate format (-show- picks an appropriate number of significant figures and will use a scientific format such as 6.7×1013, if the number is large enough to require it). By using -show- instead of -write-, you tell TUTOR that you want the stored value to be shown rather than just the characters in the tag.
The -show- command will normally choose 4 significant figures, so that a typical display might be “-23.47”. You can specify a different value by giving a second “argument” (arguments are the individual pieces of the tag of a statement):
The arguments of the -show- command can, of course, be complicated expressions:
In fact, it is a general rule that you can use complicated expressions anywhere in TUTOR statements. For example, ''draw 5rad +225,34L;123-L2,28L“!
Here is a short program which uses -show- to display a table (see Figure 4-6) of square roots of the integers from 1 to 15:
The last statement could also be written as “show NW”. 'This technique of making tables, including the use of the -do- index (N) to position the displays (as in “at 425±100N”) is an important and powerful tool.
There are other commands for displaying variables: -showe- (exponential), -showt- (tabular), -showa- (alphanumeric), -showo- (octal), and -showz- (show trailing zeroes). These are described in detail in the reference material mentioned in Appendix A.
Although -write- is basically designed for non-variable text, combinations of text and variables occur so often that TUTOR makes it easy to “embed” a -show- command within a -write-:
The embedded “s” indicates a -show- command and the remainder “13.7w,6” is its tag. Other permissible abbreviations include “o” (showo), “a” (showa), “e” (showe), “t” (showt) and “z” (showz). The above -write- statement is equivalent to: