Download TMQ Vol IV.ii - tim
Transcript
Volume IV.il THE MISOSYS QUARTERLY - Winter 1989/90 Volume IV.il can be inserted both adjacent to blank spaces and between characters in words (padded spaces and characters). On the various word processors I know, the trend is to pad only blank spaces between words on monospacing and both blank spares and character spacing on proportional. This method, number three, pads blank spaces only and is usable only with monospaced printing. If one wishes to justify proportionally spaced material, one can no longer use the present system which employs a character count as a measure of line length. The program counts the spaces and distributes the dots over them alone. This means that if one is using a very narrow printout width, the additiona: spacing may become somewhat excessive as there is a greater chance that a long non-fitting word may get forced to the next line, and there are few blank spaces to receive a given number of padding dots (as also happens on a word processor). In extreme cases, for instance if you run the program with a line width, B, (program line 70) of 20 chars., you will find that the word "PRTDEMO/BAS"in the printout strings will occupy a whole line to itself and there will be a substantial amount of blank space to the right of it, to the extent that the margin will not be justified at all on that line as there was only one space to take all the dots. Such a case is an exaggeration for the sake of illustration, and may never occur in actual practice at usual printout widths. Probably the reader who has understood method number one will be able to follow PRTDEM03; however, here are a few points which may not be obvious: Lines 130-150 scan the line to be printed, to determine the number of spaces (H%) over which dots should be spread (that's a single space between the quotes in 140). Line 160 calculates the total number of dots to be added. as a function of the number of characters backed in line 90, (G, line 110). Note carefully that the number of dots per char. (12 in the example) is entirely dependent on the printer and typeface and have based mine on the Applications for the User Tandy DMP430 manual, pages 127-128. This requires some explanation. Under "Dots per Line", the manual shows, for Compressed 12 CPI, a total of 1900. Under "Characters per Line", this typeface is listed as 158. Dividing total dots per line by total chars. per line gives us 12 dots per char. (as near as matters) which is shown in line 160 as a multiplier for G. Obviously, any other pitch, typeface 0@ printer might require recalculation based on data in the pertinent manual. Lines 180 and 190 calculate the number of dots to be added per space; when the result is fractional in line 180, it will be rounded downward by INT in 190, but that may leave us with insufficient dots. So we make up the number by adding the shortage starting at the beginning of the printout line (F%, line 200). Lines 210-250 printout the line, character by character. Line 240 compares each character with a space and when a space is found, (and provided there are dots to add) GOSIJBs to 350 which prints out the padding dots (M% dots per space). Line 360 checks the available (unused) number of dots (P%), and when there are no more, closes the loop by making the TO value of the loop one larger than on line 350 and then jumps to the NEXT instruction at 390 which Will close the loop and exit cleanly without leaving any stray loop pointers in the system. Once the dot count becomes zero, by repeated decrements in 380, the P%>0 on 240 will test untrue and there will be no more GOSUB 350 for that particular line of printout. Line 370 uses LPRINT CHR$(27);CHR$(i);, to send one dot space to the printer each time the loop encounters it. Consult your manual; your printer may perhaps use some other code for this. The dots in F%, line 200, are added at the -47- rate of one per space in 395 until exhausted. That means that however many dots are added per space by the loop in lines 350-390, there will never be more than one dot difference between the padding of one space (when F%>0) and another (when F%=0), which avoids large differences in width from space to space which might result from other algorithms for distributing dots over spaces. You may think, as I did originally, that it would be simpler to round upward by making M% one higher in 190, saving ourselves the additional task of distributing, in line 395, the shortage, Fr, calculated in line 200. But if we did that the numbers may be against us. For example, assume that we have 14 spaces to pad with 72 dots, which gives L=5.142 in line 180. If we were to round that u-@to the next integer, we would get6 dots padding per space, Line 360 would stop padding when the 72 dots have been used. The result would be that, of the 14 spaces, 12 have been padded with 6 dots each and two have not been padded at all, and the difference may be quite visible and even unacceptable to some persons. Some operators type a double space after the period at the end of a sentence when about to begin another sentence in the same paragraph. Our program looks for a space as line terminator in 90, which is discarded in printout by (B-i) in 130 and 210. However, if there were another space there (at B-i after line 90 has completed execution), the program will treat it as any other character and may print it out at a line end which would make the line appear shorter and the justification incorrect. If this were to cause any inconvenience, circumvent it by adding 100 R=B:IF MID$(AS,(B - 1),1)" THEN B=B-1 Applications for the User