More advanced print formatting
When producing a table of figures, it is useful to print at particular positions
without having to use TAB every time. If the printed items are separated by
commas the computer does this automatically:
10 MODE 135
15 REM Lines 20 & 30 help
16 REM to show character positions
20 PRINT TAB(10) "111111111122222222223"
30 PRINT "0123456789012345678901234567890"
40 PRINT 1.23,4.567,89
Running the program gives:
11111111122222222223
0123456789012345678901234567890
1.23 4.567 89
Each number is printed at the right-hand side of a column 10 characters wide.
These columns are called fields and the width of each field is set to 10
characters when the computer is switched on.
Text is printed to the left of the field, as you can see by adding:
50PRINT "Hello" ,"my" ,"friend"
which gives:
111111111122222222223
0123456789012345678901234567890
1.23 4.567 89
Hello my friend
If a number or word is longer than the field width, the item following is printed
in the next empty field. For example:
111111111122222222223
0123456789012345678901234567890
1.23 4.567 89
Congratulations my friend
The field width can be altered to vary from 0 to 255 characters:
10MODE 135
18REM set field width to 8 characters
19 REM giving 5 fields across the screen
20 @%=&08
30 PRINT TAB(8) "Income from sales regions"
C 23