7. Constructing Text

Code Examples

Code examples are portions of computer programs that you include in your document to help explain a topic. Code examples can include only the code that a person inputs into the computer, or the dialogue between a user's input and the computer's responses.

Because programming code is precise, you must reproduce the exact code, even if there are language errors in the code, such as errors in spelling, grammar, or punctuation.

To make sure that a reader can distinguish the code from standard paragraph text, consider these writing and formatting techniques:

    For instance, you can start an example on a new line, either flush under the paragraph text or indented. You can use a solid or dotted box around an example. You can use a color screen over your example, but be careful that it does not detract from readability.

    A caption highlights the example and categorizes it for a reader. If you use captions, you can compile a list of code examples in the table of contents.

For example :

    Code Example 7-1 Checking Status on the Tape Device

-------------------------------------------------------------
% mt -f /dev/rmt/0 status
Archive QIC-150 tape drive:
	sense key (0x0)= nosense     residual= 0     retries= 0
	file no= 0	block no= 0
-------------------------------------------------------------



(Continued...)