TABs and aligning columns
Posted: Fri Jan 16, 2015 7:04 am
Having used things like Microsoft Word and other relatively recent word processing programs has perhaps spoiled me and has caused me to have too great expectations of the VIC and other 8-bit systems, however, I hope all the same that there is an elegant and not-too-difficult way to modify tabs on the VIC 20 using BASIC.
What I am thinking of is finding a way, for instance, of displaying columns of figures where the decimal point is aligned correctly relative to the figure above and below it. Say that I need to produce a column of prices, which are variable (i.e., I don't know how many digits each price will comprise) but I want them to line up correctly. Similarly, I would like to be able to right-justify tabs as well, just like one can do using Word.
Off hand, I would go about this in an incredibly awkward way using LEN, LEFT$, RIGHT$ etc. in a convoluted subroutine testing and comparing the length of each variable and making the necessary adjustments, but I hope someone else has a better way.
Granted that this would be of limited value on the VIC in 22-column mode, but I am thinking of 80-columns or even for use on the 80-column CBM. In the latter case, given that the CBM (PET) held itself out to be a business computer, I am a bit disappointed that this might not have been in mind when designing BASIC. (Then again, I am not so familiar with Basic 4.0).
A machine-language routine might be in order for this; however, I suspect that would require different routines for each system, i.e., VIC vs 64 vs CBM. For now, I would be interested in considering a more portable BASIC routine.
What I am thinking of is finding a way, for instance, of displaying columns of figures where the decimal point is aligned correctly relative to the figure above and below it. Say that I need to produce a column of prices, which are variable (i.e., I don't know how many digits each price will comprise) but I want them to line up correctly. Similarly, I would like to be able to right-justify tabs as well, just like one can do using Word.
Off hand, I would go about this in an incredibly awkward way using LEN, LEFT$, RIGHT$ etc. in a convoluted subroutine testing and comparing the length of each variable and making the necessary adjustments, but I hope someone else has a better way.
Granted that this would be of limited value on the VIC in 22-column mode, but I am thinking of 80-columns or even for use on the 80-column CBM. In the latter case, given that the CBM (PET) held itself out to be a business computer, I am a bit disappointed that this might not have been in mind when designing BASIC. (Then again, I am not so familiar with Basic 4.0).
A machine-language routine might be in order for this; however, I suspect that would require different routines for each system, i.e., VIC vs 64 vs CBM. For now, I would be interested in considering a more portable BASIC routine.