Pretty Printing

Started by Blacklord, July 28, 2009, 07:29 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Blacklord


The PET system gobbles up spaces that may be left between the line number and the first character of a statement being entered, with the result that all statements in a PET BASIC program are left-justified. One of the features of a readable program is the use of blank lines and statement indentation to emphasize the logical structure of the program. This is "pretty printing" (see P. Nagin and H. F. Ledgard, "BASIC With Style", Hayden Book Company, Rochelle Park, NJ, 1978, or J. M. Nevison, "The Little Book of BASIC Style," Addison-Wesley, Reading, MA, 1978).

By now it is well known that spaces can be inserted at the beginning of a PET BASIC line if a colon (":") is typed in the first or second space following the line number.

100: FOR I = 1 TO 10
110:    X = X + 1
120: NEXT I

What may not be so well known is that there is at least one restriction on this usage. A DATA statement that is not preceded immediately by a colon is ignored! Thus, the following will not work.

110:   READ X, Y
110:   DATA 1, 2

Instead, this can be used:

100:   READ X, Y
110:   :DATA 1, 2