17.07.2016 Views

COAET" • r

Apple-Orchard-v3n2-1982-May-Jun

Apple-Orchard-v3n2-1982-May-Jun

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

APPLESOFT PROGRAM FORMATTING LISTER<br />

by David H. Bartley<br />

If I = 1 A<br />

PRlNT<br />

11 IF A' T$ GOSIJB 4075 I<br />

One of the handiest utilities for any language system is a<br />

formatting lister, or "pretty-print" routine. Having been<br />

spoiled by a good commercial Pascal pretty-printer on the<br />

job, I decided that I had to write one for use with Applesoft<br />

on the Apple at home. The built-in LIST command gives me<br />

the information I need, but it sure doesn't go out of its way to<br />

make it easy to read!<br />

Most pretty-printers I'm familiar with are designed for<br />

printer output. I wanted mine to create nice hard-copy listings,<br />

but I also wanted to make it easier to display parts of a<br />

program in the Apple's screen in a more readable form. The<br />

Assembly language program in Listing 1 is the result of my<br />

efforts to do just that.<br />

Program Features<br />

My pretty-print routine for Applesoft programs was<br />

deveby loped adding the features listed below to the algorithm<br />

used by BASIC. (The original code may be found by<br />

disassembling from $D6A5 to $D765 in the ROM.)<br />

1. The pretty-printer is easily initialized by typing "BRUN<br />

A/5 LISTER" Formatted listings are then generated by<br />

typing any of the LIST commands, preceded by an ampersand<br />

( & ). The standard arguments (one line number, or two<br />

separated by a comma, or dash), are allowed. The word<br />

"LIST' may be abbreviated to "L." Output may be to the<br />

printer, to the screen, or both.<br />

2. All program line numbers are displayed right-adjusted<br />

in the first five output columns. All program statements<br />

begin in Column 7.<br />

3. Each statement separator(:) appearing past Column<br />

12 causes a line break. The ":" is displayed in Column 4 of<br />

the following output line.<br />

4. Lines usually extend to Column 38 instead of 33. The<br />

continuation of a long line is indented three extra spaces.<br />

5. Each output line is indented an extra two spaces for<br />

each level of nested FOR. .. NEXT and IF. .. THEN statements.<br />

To avoid squeezing too closely against the right margin,<br />

indentation stops at Column 30.<br />

6. A space is listed after every comma or semicolon<br />

(except those in REMs and quoted strings).<br />

7. The output line is broken and continued whenever a<br />

space, comma, or semicolon appears past Column 33.<br />

8. No extra blanks are displayed around the " *" and ()<br />

tokens.<br />

9. A blank is not listed before a keyword if the previous<br />

character is a blank or left parenthesis.<br />

10. A blank is not listed after a keyword ending with a<br />

parenthesis (such as "TAB('', for example).<br />

11. Non-printing control characters are listed as letters<br />

enclosed within square brackets.<br />

12. The listing can be temporarily stopped and then<br />

resumed by hitting any key. Control-C may be used to<br />

cancel the listing.<br />

Operational Requirements<br />

There are a few things you need to be aware of, however.<br />

A/S LISTER must be used under DOS with Applesoft in<br />

ROM (or at the same locations in RAM card). It is not hidden<br />

above HIMEM, so it may be wiped out if your program or its<br />

data requires too much space. Another point: the"&" vector<br />

is used to enable RENUMBER; if you're using that utility<br />

while coding, you can't use the Lister, and vice versa.<br />

There is one known bug: it doesn't realize that "NEXT J,J"<br />

ends two FOR. .. NEXT loops instead of one; the indentation<br />

will be slightly off. Since it's better programming practice to<br />

use "NEXT I: NEXT J," I haven't made provision for the<br />

sloppier form.<br />

The Assembly language program in Listing 1 should be<br />

assembled and placed in the binary file "A/ S LISTER."<br />

BRUNning that file loads the program in the Apple's<br />

memory at location $6000 Uust above Hi-Res Page 2), and<br />

sets up the ampersand vector. (Obviously, the ampersand<br />

vector can't be used for more than one purpose at a time.)<br />

Once loaded and initialized with BRUN, the program may<br />

be invoked with " & LIST' any number of times.<br />

36 Apple Orchard

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!