Neat Numbers On The VIC
Daniel E. Dick
These subroutines will print numbers and display calculations on a TV or a printer in easily read columns. There are several solutions here to common formatting problems.
I use a VIC-20 and VIC-1515 printer in designing programs for my work in energy studies. I find that the familiar TAB and the CHR$(16) functions leave something to be desired when you are sending numbers to a monitor or printer. Both TAB and CHR$ left justify columns of numbers. The VIC-20 also does not include a PRINT USING statement for right justifying columns of numbers or for placing commas between numerical units in the thousands.
As you can see from these examples:
99999 is more easily read as 99,999
12345678 is more easily read as 12,345,678
And a column of numbers is more easily read (and checked for addition) if it is right justified as well. The column of numbers to the right is easier to read and total:
|
Program 1 is a short and simple program to right justify and display real numbers on the screen.
|
Program 2 right justifies and prints integers up to 999999999 (999,999,999) – VIC's limit of standard notation.
|
Program 3 right justifies and prints real numbers up to 9999999.99 (9,999,999.99) which is the limit of standard notation in the VIC-20.
|
Program 4 displays and prints specific data and calculated results in a tabular form that is legible and understandable. Programs 2 and 3 have been integrated into the main program in lines 5000-5050 and 5100-5180.
Lines 10000-10050 are a helpful subroutine for renumbering lines (published in COMPUTE!, April 1982).
Your Energy Consumption For Space Heat During Year Chosen:
|
Program 5 brings us back full circle to Program 1, with line 15 transferring control to the printer.
OUTPUT .01 .1 1 10 100 1000 |