Knowledge Base‎ > ‎Programming‎ > ‎Turing‎ > ‎

Formatting Output

Sending Output to the Screen

Sending output to the screen is done using the put command:

put "this is a message to the user"

When outputting information to the screen you have several ways you can combine and format the output.

Multiple Items to Output

Output several chunks of information on one line:

put 10, " little monkeys jumping on the bed.", 1, " fell down and bumped his head"

The comma simply seperates each chunk and the keeps printing the output on the same line. When Turing reach another put statement the new put statement will appear on the next line.

You can have the next put statement stay on the same line of a previous put statement if you use end the previous statement with a double period:

put 10, " little monkeys jumping on the bed."..
put 1, " fell down and bumped his head"

Special Characters

There are several special charcters that can be used when printing as well which are preceded by a backslash (\):

put "this is a tab \t which \t moves ahead several spaces"
put "this is a \" - so that how you can print things in quotes - \"like this\""
put "these are \n new lines \n all coming from the \n the same put statement"
put "this is a backslash \\"

Fields and Rounding

Often you want to be able to align text more carefully with other things on the screen. Consider the following table:

 Student
 23987923
 29123211
 Quiz 1
 45
 82
 Test 1
 65  
 91


put "Student \tQuiz 1 \tTest 1"
put "23987923\t", 45:8, 65:8
put "29123211\t", 82:8, 91:8

The :8 in the second and third put statements are the field size. A field is like a text box of a certain width, in this case 8 spaces wide. The numbers being printed are printed into the text box right aligned and the rest of the field is filled with spaces.

A second number can be specified to indicate how many decimal places a number will be rounded to:

put "Student \tQuiz 1 \tTest 1"
put "23987923\t", 45.86:8:1, 65.3333:8:1



Comments