JUSTIFY.DOC 22 March 1988 Page 1 INTRODUCTION: ------------ The word "justify" as used in this discussion means "to fit exactly, to fill a full line." Consequently, a program that justifies will fill each line to the same width, producing even margins on both sides of the page. To do this with a normal typewriter or computer display requires inserting "fill blanks" (extra spaces) between words at various plaes on the line. No matter how this is accomplished, it produces text that has "holes" in it. This detracts to some extent from reading that text in a normal manner. Adding these extra "fill blanks" in the least obtrusive manner then becomes very important. WordStar (currently version 4.0) is by a wide margin the most popular word processor program for people with CP/M com- puters. Ironically this is the very worst program available with regard to adding fill blanks for justification. You may wish at this time to stop and read the FORMAT.INF file which is included as part of the JUSTIFY.LBR. It goes into some depth showing why this statement is not overstated and shows examples of the juvenile method WordStar uses. (I've been known in the past to say even a child in Kindergarten could have thought up a better method.) For WordStar 4.0, then: To quickly summarize, the first fill blank needed is always placed between the last two words on the right side. The second is always placed between the first two words. Any others alternate from right to left. This means every line not already the correct length will have an extra blank between the last two words. The worst case would be where you need three or more additional fill blanks and the end of the sentence is something like this: ...this is the end of the sentence. I ^^ two blanks after justification with WordStar 4.0, the same line: ...this is the end of the sentence. I ^^^^ four blanks This "worst possible case" is not as unusual with the WordStar program as you might at first think. Winding up with three sequential blanks is quite common. JUSTIFY.DOC 22 March 1988 Page 2 WHY "YET ANOTHER" PROGRAM? ------------------------- I started to write a new .DOC file for a different program I have been working with for some time. A comparable program with a fine .DOC file already exists. It was written via WordStar and justified to 64 columns. In trying to read that file, I kept getting distracted by the manner in which WordStar justifies its text. I kept wanting to redo that part so I could then read the text for content rather than be annoyed by the format. The manual did look great, from a distance. I thought my .DOC file might look better if it had justified margins. To do this I needed two things: 1) a program that would insert fill characters in a more logical manner than WordStar, and 2) Since I don't use/care for WordStar, would need to ob- tain another program for that purpose. About that time, somebody uploaded ALPHA20.LBR to the local BBS that I operate. It meant I could write the text (as I am doing now) with my normal editor (VEDIT, in my case) and then run it through a format pro- gram to add justification. Unfortuantely that fizzled out when I found that ALPHATXT does not recognize lines already the correct length. It was essentially a program that wants to format files and then add justification. I then heard of ROFF4 and later RNF13. Both these programs are patterned after an UNIX program of the early 80's called RUNOFF. They both do an excellent job of reformatting and will quit at that point if you like. Just what I wanted. In fact, as the examples in FORMAT.INF show, these programs can take badly munged text and make it into a perfectly formatted output file. They will also justify to even margins while formatting, if you wish. Either was quite close to what I had in mind. However ROFF4 doesn't properly justify lines already the proper length and thinks they are one character too long. All these programs mentioned so far have the same fault illustrated above for WordStar - they can wind up with four blanks in a row. Three at these locations is commonplace. Although both these programs alternate from right side to left side with fill blanks, they always start with the last two words on one line and the first two words on the next line. IRV'S JUSTIFY PROGRAM --------------------- I decided it was time I stop 'just thinking about' a program I had written in 1976 for ham radio use and adapt it to CP/M. At that time I assumed my work would be considered very elementary by any professional programmer. It was an interesting program that would justify conversa- tional messages, as you typed them, in real time, over ham radio. JUSTIFY.DOC 22 March 1988 Page 3 The program JUSTIFY.COM uses that scheme. Here are some of the more interesting features it has: 1) Never puts an extra 'fill blank' between the first two or last two words, unless those are required. 2) Justifies the center of the first line, right side of the second line and left side of the third line. Note: always moves in one additional word at each end, to do this as mentioned in statement 1) 3) Never puts any extra blanks in a location where two blanks already exist. 4) Fills the final line of a paragraph if it is within 4 characters of normal length. Not much more comment is needed about most of these statements. You are already interested in this topic and have been following what we are discussing - or you never made it this far, anyway. HOW TO USE JUSTIFY.COM ---------------------- If you have thought for some time a better method than what WordStar offers would be "nice to have" and you have looked at the examples shown in FORMAT.INF, you might want to try using JUSTIFY.COM. It's VERY fast and very simple to use. First you prepare the text with your favorite editor, even WordStar in the non-document mode is fine. Note: JUSTIFY.COM is based on our FILT7 program. It removes high bits set, imbedded control characters, expands tabs, removes trailing spaces, orphan line feeds, etc. Then you can go back over the text and insert any special characters that might be beneficial to JUSTIFY.COM - more on that later, normally none are needed. JUSTIFY.DOC 22 March 1988 Page 4 HELP GUIDE: ----------- Assuming you renamed the file JUS.COM so you can type it easily, you would get this help guide by just typing: JUS at the CP/M prompt: B0>JUS JUSTIFY - Irv Hoff - copyright 1988 To use: B>JUS HELLO.TXT FINAL.TXT (1) B>JUS A:HELLO.TXT B:FINAL.TXT (2) (1) Justifies HELLO.TXT into new file called FINAL.TXT, both are on the current drive. (2) Justifies HELLO.TXT on the A: drive into new file on the B: drive called FINAL.TXT. In first column: ) center this line ] justify this indented paragraph ; do not justify this line 0103h Line width for justifying 0104h 0=No FF=Yes - justify lines starting with a space 0105h 0=No FF=Yes - justify regardless of original length 0106h 0=No FF=Yes - retain any imbedded form feeds B0> OPERATION: --------- When ready to go, you type the name of the program to be justified and the name you want the new file to be called. You would get the fol- lowing display. If you just hit for the answers, the default values (Y,N,Y) are shown/used. Else you can enter you own pre- ferences for "this run". (Whatever you think is faster, easier or more convenient.) B0>JUS TEST.TXT TEST1.JUS JUSTIFY - Irv Hoff - copyright 1988 A displays, retains default value, which may be changed at the address shown. If some lines need more spaces, must say YES to totally "fill line", but will then justify even short lines. 104h - justify lines starting with a space? (y/n): Y 105h - justify regardless of original length? (y/n): N 106h - retain any imbedded form feeds? (y/n): Y JUSTIFY.DOC 22 March 1988 Page 5 OPTIONS: ------- A few 'special characters' were shown on the help guide. Normallly none of these are required. You may want to center some line, since it is so easy to do. Just type the ')' character at the left margin and then move the line to be centered against that character, like: )This line will be centered )So Will this one )This too That only leaves two special characters. The ']' forces justifica- tion on lines that are indented, when you have selected "No, do not jus- tify indented lines" otherwise. The ']' will be changed to a space, so the length of your line and the number of columns you intended will be kept intact. The other special character is the ';'. It prevents justification of that line. It would be seldom used. More regarding the ']' and ';' when we discuss the "justify indented lines" and "justify regardless". OPTION 1 - JUSTIFY INDENTED LINES --------------------------------- Some things you write, you might wish to indent the first line of each paragraph. In that case you would certainly want to jusifty those indented lines. There are two ways to do this. (1) use yes for option one: 104h - justify lines starting with a space? (y/n): Y or (2) use a ']' character in the first column of each of those lines. The first requires nothing special in the actual text file. However, if you have OTHER lines that are also indented (like the example four lines up from here) that would also be justified. In that case you would need to use a ';' in front of each line NOT to be justified. These two characters give a tremendous amount of flexibility to the program. You can choose whatever is most convenient for you, or what is easiest to remember. The built-in displays are a permanent reminder of what is available. The addresses shown would allow you to change the defaults to whatever you find you are normally using. OPTION 2 - JUSTIFY REGARDLESS ----------------------------- A normal 72 column line (such as this) has from 10-12 spaces between words. With any effort at all, you can write text that seldom requires more than 3-4 'fill blanks' to justify the line. It would be very rare the line would not have "oodles of potential area" for adding the extra blanks. With the "fill regardless set to yes", blanks would be added until the line would be justified. Short lines would even get the full treatment, then: JUSTIFY.DOC 22 March 1988 Page 6 such as this one That could have been prevented by using: ;such as this one The ';' would have dropped off and the word 'such' then started at the left margin. However, by leaving the "justify regardless" turned off, short lines are left intact and all but the very worst lines will be justified. If not, chances are excellent that the lengthy word on the next line can be hyphenated, allowing part of it to be placed on the current line. (You will notice I have done that in a few places on this file, in an effort to minimize the number of 'fill blanks' needed.) SUMMARY OF OPTIONS: ------------------ Although there are very few options, for most text files, NONE are needed. You can decide for yourself whether using the "Do not justify indented lines" and the occasional use of ']' to force justification of indented paragraphs or instead saying "Yes, justify indented lines" and then the occasional use of ';' to not justify some indented lines that would look weird otherwise. Whatever minimizes the extra editing prior to using JUSTIFY. Most of the time NO special characters are needed. CONCLUSION: ---------- Writing text with your favorite editor (even WordStar) with the idea of then using JUSTIFY.COM to make even margins, should give results most people would consider well worth calling up the extra program. If you have an editor that cannot justify the text it prepares, then this pro- gram gives you that capability. If you have been unhappy with the way WordStar (or other word processors) insert the fill blanks, you might prefer using JUSTIFY. It is so very fast and so easy to use, you might even go out of your way to put out justified text, now. (I've been using it extensively on the pre-typed messages I write for batch uploading to CompuServe.) By using ROFF4 or RNF13, you can re-format existing text files to 72 columns and then run them through JUSTIFY quite quickly and easily. You might indeed prefer the new appearance of those files. - Irv Hoff W6FFC (415) 948-2166 - voice (415) 948-2513 - PRACSA RCPM